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

回答(1 个)

Kevin Holly
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 个评论
Pooneh Shah Malekpoor
thanks for your response. This is the code I have written with respect to my specific problem. Now how can I mesh grid the resulting figure?
T = readtable('table.xlsx');
T(1:9,1:4)
TS = table2array(T);
k=[0.3 0.4];
kk = length(k) ;
t = TS(:,1) ;
data = TS(:,3:4) ;
figure
hold on
for i = 1:kk
plot3(k(i)*ones(size(t)),t,data(:,i))
end
view(3)
line(k,[t(1) t(1)],[data(1) data(1)],'Color','g')
line(k,[t(end) t(end)],[data(end) data(end)],'Color','g')
view(90,30)
Kevin Holly
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 CenterFile Exchange 中查找有关 Computational Geometry 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by