Clear Filters
Clear Filters

I am trying to determine the angular acceleration by applying the central difference technique?

1 view (last 30 days)
I am trying to applied the central difference technique formula into my code but I am having trouble with the output. I am trying to determine the angular acceleration of by using the knee angle. I need to plot my ang_acc vs time . I am also using this formula: (x_(i+2)-2x_i+x_(i-2))/(4∆t^2 )
fs = 69.9;
t = [1/fs:1/fs:length(ankle)/fs];
fc = [.1:.1:(fs/2)-.1]';
n = length(fs);
%% Step 1: Calculate Knee Angle
% hip -knee represent the end points of the thigh segment angle
%fibula-ankle represent the end points of the leg segment angle
theta21_thigh = atan2(hip(:,2)-knee(:,2),hip(:,1)-knee(:,1));
theta43_leg = atan2(fibula(:,2)-ankle(:,2),fibula(:,1)-ankle(:,1));
theta_knee = theta21_thigh - theta43_leg;
%% Step 2: Angular acceleration of the knee (central difference):
angular_acc = ((theta_knee(3:end))-(2*theta_knee)+(theta_knee(1:end-2))) ./(4*(106).^2);
Sindar on 28 Sep 2020
is it throwing an error?
may be as simple as:
angular_acc = ((theta_knee(3:end))-(2*theta_knee(2:end-1))+(theta_knee(1:end-2))) ./(4*(106).^2);
(if you want the first and last point using forward/backward difference, you could just define those separately)

Sign in to comment.

Accepted Answer

Nagasai Bharat
Nagasai Bharat on 1 Oct 2020
The error is due to the difference in the sizes of the operands i.e., knee_angle has a size different from knee_angle(1:end-2) and knee_angle(3:end).
Please look into the dimensions to eliminate the error.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!