compute_derivative: Compute Derivative of Data

View source: R/compute_derivative.R

compute_derivativeR Documentation

Compute Derivative of Data

Description

This function computes the derivative of data (e.g., angular position) using either a smooth spline fit or numerical gradient.

Usage

compute_derivative(x, y, method = c("spline", "gradient"), deriv = 1)

Arguments

x

A numeric vector representing the independent variable (e.g., time).

y

A numeric vector representing the dependent variable (e.g., angular position).

method

A character string specifying the method to compute the derivative. Options are "spline" for smooth spline fitting or "gradient" for numerical gradient using pracma::gradient. Default is "spline".

deriv

An integer specifying the order of the derivative. Default is 1 for the first derivative. Higher values (e.g., 2) will return higher derivatives (second derivative, etc.).

Value

A numeric vector representing the derivative (e.g., angular velocity or acceleration).


Kneerav/biomechanics documentation built on July 16, 2025, 4:51 p.m.