plot 2 vectors in 3D plot

조회 수: 3 (최근 30일)
maurizio
maurizio 2011년 2월 8일
Hello everybody,
I would like to plot 2 vectors, but the second one should be shifted, in order to have a 3D plot with two lines, one for each vector. I had a look at the documentation but I could not find anything like that, and I don't want to plot an extrapolated surface out of this 2 vectors.
Any idea?
regards
Maurizio

답변 (3개)

maurizio
maurizio 2011년 2월 8일
FOUND:
A = [1 2 3 4 5 6 7 8 9 10];
B = [5 4 3 2 1 1 2 3 4 5];
C = ones(1, length(A));
D = 2.* ones(1, length(A));
figure(1)
plot3(1:length(A),C,A);
grid on
hold all
plot3(1:length(A),D,B);
legend('A','B')
xlabel('X');
view(-18,30)
maybe you know some better way.
thanks
Maurizio

Walter Roberson
Walter Roberson 2011년 2월 8일
C = ones(length(A),1);
plot3(1:length(A),[C,C+1],[A(:),B(:)]);
You don't really need D, and you don't need the 'hold all' if you plot both lines in one call.

maurizio
maurizio 2011년 2월 10일
Thanks!

카테고리

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