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!