필터 지우기
필터 지우기

How to draw a complicated graph

조회 수: 1 (최근 30일)
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2022년 6월 10일
댓글: Kevin Holly 2022년 6월 10일
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
Pooneh Shah Malekpoor 2022년 6월 10일
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에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by