I am trying to analyze two segment angles using vector coding (as described in Needham et al. J of Biomechanics 2014). I get an error then it comes to the atan2 function. Below is my current code. Can you please offer any suggestions.
function [Coupling_angle, mean_coupling_angle, CP_SD]= mean_coupling_angle(Array1,Array2);
ang_conversion=180/pi;
[r1 c1] = size (Array1);
for i = 1:r1-1
x(i,: )=Array1(i+1,1)-Array1(i,1);
y(i,: )=Array2(i+1,1)-Array2(i,1);
ang(i,: )=y(i,: )/x(i,: );
% convert degrees to radians
angRad = deg2rad(ang);
CP_ang(i,: )=atan2(ang(i,: ));
% convert coupling angle in radians to degrees
CP_ang = rad2deg(CP_ang)
Coupling_angle=CP_ang;
end
function [Coupling_angle, mean_coupling_angle, CP_SD]= mean_coupling_angle(Array1,Array2);
ang_conversion=180/pi;
[r1 c1] = size (Array1);
for i = 1:r1-1
x(i,: )=Array1(i+1,1)-Array1(i,1);
y(i,: )=Array2(i+1,1)-Array2(i,1);
ang(i,: )=y(i,: )/x(i,: );
% convert degrees to radians
angRad = deg2rad(ang);
CP_ang(i,: )=atan2(ang(i,: ));
% convert coupling angle in radians to degrees
CP_ang = rad2deg(CP_ang)
Coupling_angle=CP_ang;
end
Comment