How to make the 3d plot?

조회 수: 4 (최근 30일)
Hoon Jung
Hoon Jung 2020년 3월 21일
댓글: Walter Roberson 2020년 3월 21일
vertex=[3 5 3 ; 7 5 5 ; 3 5 5 ; 3 6 5 ; 3 6 3];
face= [1 2 3 ; 2 3 4 ; 1 2 5 ; 2 4 5];
patch('Faces',face,'Vertices',vertex,'Facecolor',[0.8 0.8 1]);
view(3);
grid on
vertex=[3 5 3 ; 3 5 5 ; 3 6 5 ; 3 6 3];
face= [1 ; 2 ; 3 ; 4 ];
patch('Faces',face,'Vertices',vertex,'Facecolor',[0.8 0.8 1]);
view(3);
grid on
Hi guys i got confused about ploting 3-D pyramid.
Here ara the edge coordinates of the pyramid.
How can i plot it with all of its surfaces ?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 3월 21일
vertex=[3 5 3 ; 7 5 5 ; 3 5 5 ; 3 6 5 ; 3 6 3];
face= [1 2 3 nan; 2 3 4 nan; 1 2 5 nan; 2 4 5 nan; 1 3 4 5];
patch('Faces',face,'Vertices',vertex,'Facecolor',[0.8 0.8 1]);
view(3);
grid on
  댓글 수: 4
Hoon Jung
Hoon Jung 2020년 3월 21일
편집: Walter Roberson 2020년 3월 21일
dont working .. now i use the my cell phone matlab can you show me your total code and picture ..? Sorry again ask .. and really thaks so much teach me !
Walter Roberson
Walter Roberson 2020년 3월 21일
Total code:
vertex=[3 5 3 ; 7 5 5 ; 3 5 5 ; 3 6 5 ; 3 6 3];
face= [1 2 3 nan; 2 3 4 nan; 1 2 5 nan; 2 4 5 nan; 1 3 4 5];
patch('Faces',face,'Vertices',vertex,'Facecolor',[0.8 0.8 1]);
view(3);
grid on
The output:
This is correct output. You can use the plot tools to rotate it to see other faces.
The initial part of your original attempt was:
Notice the line from the bottom left corner. That is the internal edge of the corner "behind" the view, and it is visible because your original attempt did not draw the square face at the base of the pyramid. In the code I posted, you can tell that the square face has been drawn because that line is not visible.
If you want to see with more emphasis:
vertex=[3 5 3 ; 7 5 5 ; 3 5 5 ; 3 6 5 ; 3 6 3];
face= [1 2 3 nan; 2 3 4 nan; 1 2 5 nan; 2 4 5 nan; 1 3 4 5];
patch('Faces',face,'Vertices',vertex,'FaceVertexCData', hsv(size(vertex,1)));
shading interp
view(3);
grid on

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by