How can I plot three 2D functions in one 3D graph?

조회 수: 18 (최근 30일)
Mr.Alb
Mr.Alb 2022년 2월 10일
댓글: Mr.Alb 2022년 2월 10일
Hi everyone,
I have three 2D graphs, i.e.:
1) x-y 2)x-z 3)y-z
I need to put them all into a single 3D graph like in this example:
Any idea how to do that?
Thanks
  댓글 수: 2
KSSV
KSSV 2022년 2월 10일
Plot each 2D grph using hold on.
Mr.Alb
Mr.Alb 2022년 2월 10일
How that's possible? I mean if it was
hold on
plot(x, y)
plot(z, y)
plot(z, x)
hold off
they would be overlayed in a single 2d plot. How would you implement that?

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

채택된 답변

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2022년 2월 10일
a simple way i thing is using plot3:
plot3 function, plot a curve in 3D space. if you set all values of one component 0. the curve will be on plane.
for example a ploting y=f(x) on X-Y plane means it's 3D curve is on Z=0 plane.
figure; hold on; grid on
X = 0:0.01:1;
Y = sin(X);
plot3(X,Y,zeros(numel(X),1),'Linewidth',2);
Z = tanh(X).*X;
plot3(X,zeros(numel(X),1),Z,'Linewidth',2);
Y = 0:0.01:1;
Z = Y.^2;
plot3(zeros(numel(Y),1),Y,Z,'Linewidth',2);
view([0.8 1 1])
xlabel('X');ylabel('Y');zlabel('Z')
  댓글 수: 1
Mr.Alb
Mr.Alb 2022년 2월 10일
simple and effective! Many thanks. This solved

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by