3d plot plotting in 2d and 2d plot plotting in 3d.
조회 수: 47 (최근 30일)
이전 댓글 표시
Hello,
I am plotting both a 3d plot and 2d plot, using "plot3" to plot the 3d plot and "plot" to plot the 2d plot. When I do either or seperately, they plot fine. However, trying to plot them together in the same code results in the 3d plot being plotted in 2d, and the 2d plot being plotted in 3d.
The code is long, but the plotting sections are basically this (where x y z is one set of data, and a b is a different set of data):
figure(1)
hold on
plot3(x,y,z)
hold off
figure(2)
hold on
plot(a,b)
hold off
댓글 수: 0
답변 (2개)
Eamon Gekakis
2022년 6월 24일
Remove the holds from the code, you do not need to specify hold on/off if you are plotting two separate figures
figure(1)
plot3(x,y,z)
figure(2)
plot(a,b)
This may work better
댓글 수: 0
Star Strider
2022년 6월 24일
The must both plot in 3D, however the ‘z’ value of the 2D plot can be whatever you want (here, 10) —
x = 0:0.5:5;
y = 0:0.2:2;
z = x.^2 + y.^2;
a = x;
b = sqrt(x);
figure(1)
hold on
plot3(x,y,z, '-b')
% hold off
% figure(2)
hold on
plot3(a,b,zeros(size(a))+10,'-r')
hold off
view(30,30)
grid on
xlabel('(x),(a)')
ylabel('(y),(b)')
zlabel('z')
The zeros (constant) vector can be on any axis. I chose ‘z’ here.
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!