trapezoidal_integration {workloopR} | R Documentation |
Approximate the definite integral via the trapezoidal rule
Description
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
.
Usage
trapezoidal_integration(x, f)
Arguments
x |
a variable, e.g. vector of positions |
f |
integrand, e.g. vector of forces |
Details
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.
Value
A numerical value indicating the value of the integral.
Author(s)
Vikram B. Baliga
References
Atkinson, Kendall E. (1989), An Introduction to Numerical Analysis (2nd ed.), New York: John Wiley & Sons
See Also
analyze_workloop
,
read_analyze_wl
,
read_analyze_wl_dir
Examples
# 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
[Package workloopR version 1.1.4 Index]