I need some help with forming a loop to plot some data.
I have five skeletal joints; each JOINT matrix contains an x,y & z coordinate at a certain point in time. x, y and z are the columns, the coordinates in each row. e.g.
x y z
0.5 0.6 1.3
The four joints are synchronised, the same row in each JOINTS 1, 2 3 and 4 was captured at the same time. I am trying to join these joints up to see what how the user was moving their arm. For reference these are the joints that were captured in the right arm. Joint 1 = shoulder, 2 = elbow, 3 = wrist, 4 = hand.
I wish to be able to plot these joints continuously by going through each row and plotting the line. The matrix size always changes based on the person I am tracking, so I need to loop through each rows of the matrices for joints 1, 2, 3 and 4 and plot the line, increment a row, then plot the next line.
Minimal Example:
J = JOINT(1,:)
% Joint rows varies between each user. I would like a function to
% extract rows, plot, move onto next row, plot. (ideally with a second delay)
X1 = J(:,1);
Y1 = J(:,2);
Z1 = J(:,3);
line(X1 Y1 Z1)
Actual Code:
CA = JOINT1(13,:);
CB = JOINT2(13,:);
CC = JOINT3(13,:);
CD = JOINT4(13,:);
X1 = CA(:,1);
Y1 = CA(:,2);
Z1 = CA(:,3);
X2 = CB(:,1);
Y2 = CB(:,2);
Z2 = CB(:,3);
X3 = CC(:,1);
Y3 = CC(:,2);
Z3 = CC(:,3);
X4 = CD(:,1);
Y4 = CD(:,2);
Z4 = CD(:,3);
line([X1, X2, X3, X4],[Y1, Y2, Y3, Y4], [Z1, Z2, Z3, Z4]);
so I assume it would be something like
[x y] = size(JOINT1);
figure;
for i=1:x
plot(JOINT1(i,:));
hold on;
plot(JOINT2(i,:));
end
I would like to see these on a one second delay, but I can attempt this myself once I automate this method of plotting!
Additionally, if anyone is aware of how I can plot a circle on the coordinates of each joint (e.g. X1, Y1, Z1) that would also be very handy as eventually I would like to look at the angles between joints.
Any help would be appreciated