3D matrix - 2 D plot, how to make a plot ?
4 views (last 30 days)
Show older comments
I have a 3D 3*3 matrix, that I had in a loop and it got repeated 202 times. The matrix consists of x,y,z.I would like to make a 2D-plot of all the x, y and z against the sample numbers (202). So just three lines on the plot in the end. When I do the plot function I now get hundred of lines, I don't want that. Can anybody help ?
for i= [1:202];
origin2=(LE(:,i)+ME(:,i))/2;
Y2=(FH(:,i)-origin2)/norm(FH(:,i)-origin2);
ztemp2=(FH(:,i)-ME(:,i))/norm(FH(:,i)-ME(:,i));
x2=cross(Y2,ztemp2);
X2=x2/norm(x2);
z2=cross(X2,Y2);
Z2=z2/norm(z2);
R2(:,:,i)=[X2 Y2 Z2];
midpoint=(LM(:,i)+MM(:,i))/2;
mid=(MLP(:,i)+MMP(:,i))/2;
Y3=(mid-midpoint)/norm(mid-midpoint);
ztemp3=(LM(:,i)-MM(:,i))/norm(LM(:,i)-MM(:,i));
x3=cross(Y3,ztemp3);
X3=x3/norm(x3);
z3=cross(X3,Y3);
Z3=z3/norm(z3);
R3(:,:,i)=[X3 Y3 Z3];
relor(:,:,i)=R2(:,:,i)\R3(:,:,i);
hold on
t=1:202;
plot(t,relor(1,1,:))
hold off
end
0 Comments
Answers (2)
David Sanchez
on 18 Feb 2014
Plot the data after the finishing the loop.
plot(t,x,t,y,t,z)
Just add your x,y,z data. Your code is a bit confusing.
3 Comments
Iain
on 18 Feb 2014
Have you tried:
plot(relor(:,:,1)') %?
If you do it explicitly, you'll get exactly what you want:
plot(relor(:,1,1),'r') % 1st column in red.
hold on % to stop overwriting...
plot(relor(:,2,1),'k') % 2nd column in black
plot(relor(:,3,1),'gx') % 3rd column in green crosses.
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!