How to make the 3d plot?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 ?
0 comentarios
Respuestas (1)
Walter Roberson
el 21 de Mzo. de 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 comentarios
Walter Roberson
el 21 de Mzo. de 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

Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!