필터 지우기
필터 지우기

Plot a 3d-plane in MATLAB??

조회 수: 6 (최근 30일)
Nghia
Nghia 2014년 5월 22일
편집: Nghia 2014년 5월 26일
I want to plot a 3d-plane (x=0) in MATLAB, (-2<=y<=2) and limited by the line z=4-y^2. Here's my code :
y=linspace(-2,2,50);
z=4-y.^2;
[Y Z]=meshgrid(y,z);
X=0*Y+0*Z;
mesh(X,Y,Z);
axis tight;
Can you give me any hints???? thank you very much!!
  댓글 수: 2
Walter Roberson
Walter Roberson 2014년 5월 22일
편집: Walter Roberson 2014년 5월 22일
When you say that the plane is to be limited by that z, and that you want to draw plot it, then what difference is there compared to plotting a single curved line in 3 space?
Nghia
Nghia 2014년 5월 22일
편집: Nghia 2014년 5월 22일
I'm not clear what you're trying to ask but the code which I posted plot just a single curved line in 3 space, but what I want is to plot a plane x=0 and limited by both the line z=0 and z=4-y^2 I mean that I want to use to plot a plane surfc(x,y,z)

댓글을 달려면 로그인하십시오.

채택된 답변

Hugo
Hugo 2014년 5월 22일
This solution is based on patch
y=-2:.01:2;
z=4-y.^2;
numy=length(y);
% Constructing the vertices
V=zeros(numy,3);
for iy=1:numy,
V(iy,:)=[0,y(iy),z(iy)]; % Vertices in the parabola
V(iy+numy,:)=[0,y(iy),0]; % Vertices in the y axis
end
% Constructing faces
F=zeros(numy-1,4); for iy=1:numy-1, F(iy,:)=[iy,iy+1,iy+1+numy,iy+numy]; end
patch('Vertices',V,'Faces',F)
The plot may look like a line. You just need to rotate it and you will see the figure in 3D.
Hope this helps.
  댓글 수: 2
Nghia
Nghia 2014년 5월 22일
thank you for your help!
Nghia
Nghia 2014년 5월 26일
편집: Nghia 2014년 5월 26일
I have tried your code then I rewrite like this
%code patch('Vertices',V,'Faces',F,'FaceColor',[1 0 0])
but it doesn't change the face's color and it's still black. How can I fix this?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by