3D matrix - 2 D plot, how to make a plot ?

4 visualizzazioni (ultimi 30 giorni)
N
N il 18 Feb 2014
Commentato: N il 18 Feb 2014
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

Risposte (2)

David Sanchez
David Sanchez il 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 Commenti
David Sanchez
David Sanchez il 18 Feb 2014
relor(:,:,1) is a 2D matrix, who are x,y and z?
N
N il 18 Feb 2014
oh I thought it was a 3D matrix, they told me it was.. So I have an R2(:,:,i)=[X2 Y2 Z2] and an R3 that is build up the same way.From this I calculate the relor. And this I then want to put in a plot, so the first three datapoints are X

Accedi per commentare.


Iain
Iain il 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.
  1 Commento
N
N il 18 Feb 2014
I get a blank plot when I use this.. Should I place somehing before it or place it on a specific place ?

Accedi per commentare.

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by