## Re: vector coding

Hi,

I have dabbled in vector coding. See below for code I dug up and reference. The last for loop could be eliminated with a more efficient logic test, but I am too lazy to change it.

% this program computes the phase angle between two joint/segment angles joint1 and joint2 (e.g. 100 pt data)
function [phsang] = VectCodeTrials(joint1,joint2)

% find the difference between each point in time
% this will leave you with one less point than the entry matrix
xd=diff(joint1);
yd=diff(joint2);

% find the vector magnitude between each xd-yd pair
% use ./ to do the operation on each pt instantly
vmag =sqrt(xd.^2+yd.^2);

% cosine and sine for each xd yd pair
cosang=xd./vmag;
sinang=yd./vmag;

%find the phase angle for all 99 points
phsang=atan2(sinang, cosang)*(180/pi);

[r,c]=size(phsang);
for j = 1:r
if phsang(j,1) < 0
phsang(j,1) = phsang(j,1) + 360;
end
end
end

Chang, R., Van Emmerik, R., Hamill, J., 2008. Quantifying rearfoot-forefoot coordination in human walking. J. Biomech. 41 (14), 3101–3105.