View source: R/analysis_functions.R
trapezoidal_integration | R Documentation |
Mostly meant for internal use in our analysis functions, but made available
for other use cases. Accordingly, it does not strictly rely on objects of
class muscle_stim
.
trapezoidal_integration(x, f)
x |
a variable, e.g. vector of positions |
f |
integrand, e.g. vector of forces |
In the functions analyze_workloop()
, read_analyze_wl()
, and read_analyze_wl_dir()
, work is calculated as the difference
between the integral of the upper curve and the integral of the lower curve
of a work loop.
A numerical value indicating the value of the integral.
Vikram B. Baliga
Atkinson, Kendall E. (1989), An Introduction to Numerical Analysis (2nd ed.), New York: John Wiley & Sons
analyze_workloop
,
read_analyze_wl
,
read_analyze_wl_dir
# create a circle centered at (x = 10, y = 20) with radius 2
t <- seq(0, 2 * pi, length = 1000)
coords <- t(rbind(10 + sin(t) * 2, 20 + cos(t) * 2))
# use the function to get the area
trapezoidal_integration(coords[, 1], coords[, 2])
# does it match (pi * r^2)?
3.14159265358 * (2^2) # very close
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.