필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
N
N 2014년 2월 18일
댓글: N 2014년 2월 18일
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

답변 (2개)

David Sanchez
David Sanchez 2014년 2월 18일
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
David Sanchez
David Sanchez 2014년 2월 18일
relor(:,:,1) is a 2D matrix, who are x,y and z?
N
N 2014년 2월 18일
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

댓글을 달려면 로그인하십시오.


Iain
Iain 2014년 2월 18일
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
N
N 2014년 2월 18일
I get a blank plot when I use this.. Should I place somehing before it or place it on a specific place ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by