How to draw a complicated graph
3 次查看(过去 30 天)
显示 更早的评论
Hello
This is the simplest form of the graph that I want to plot. At first, I am going to draw the x-Z-Y graph when K=0. Imagine that I draw the second graph when K=2. Then, I want to connect the two curves and obtain the surface ABCD. The output surface is of graphical importance to me. How should I draw such a thing and obtain surface ABCD in MATLAB?
Bests
Pooneh
0 个评论
回答(1 个)
Kevin Holly
2022-6-10
编辑:Kevin Holly
2022-6-10
Z=1:100;
Y=Z.^2;
K=2;
figure
plot3(zeros(size(Z)),Z,Y,'k')
hold on
plot3(K*(ones(size(Z))),Z,Y,'r')
line([0 K],[Z(1) Z(1)],[Y(1) Y(1)],'Color','g')
line([0 K],[Z(end) Z(end)],[Y(end) Y(end)],'Color','g')
view(90,30)
text(0,Z(1),Y(1)+500,'A','Color','b')
text(0,Z(end),Y(end)+500,'B','Color','b')
text(K,Z(1),Y(1)+500,'D','Color','b')
text(K,Z(end),Y(end)+500,'C','Color','b')
xlabel('x')
ylabel('Z')
zlabel('Y')
figure
V = meshgrid(Y,[0 K]);
surf(V)
xlabel('Z')
ylabel('x')
zlabel('Y')
2 个评论
Kevin Holly
2022-6-10
x=-15:15;
data(:,1) = x.^2;
data(:,2) = x.^3;
k=[0.3 0.4];
figure
plot3(0.4*ones(size(x)),x,data(:,1))
hold on
plot3(0.3*ones(size(x)),x,data(:,2))
You could just use surf(x,y,z) format
figure
surf(data',[x;x],[0.3*ones(size(x));0.4*ones(size(x))])
xlabel('Z')
ylabel('x')
zlabel('Y')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computational Geometry 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!