How to make the 3d plot?

4 views (last 30 days)
Hoon Jung
Hoon Jung on 21 Mar 2020
Commented: Walter Roberson on 21 Mar 2020
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 ?

Answers (1)

Walter Roberson
Walter Roberson on 21 Mar 2020
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 Comments
Hoon Jung
Hoon Jung on 21 Mar 2020
Edited: Walter Roberson on 21 Mar 2020
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 on 21 Mar 2020
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

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!