Special plot3 command in Matlab
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi. I have a matrix named S, e.g.
S =
[25 4 14
26 4 14
27 4 14
28 4 14
29 4 14
30 4 14
31 4 14
32 4 14
33 4 14];
Every row in matrix S indicates a point in 3D space. I want to use plot3 command to plot these points.
plot3(S(:,1),S(:,2),S(:,3),'s')
This code plots these points with squares, but I want to have cubes instead of squares. How can I do that?
Thanks.
0 Commenti
Risposta accettata
Jan
il 2 Dic 2017
As you can find the in the documentation of plot3, or to be exact at the link to "line properties", cubes are not a recognized marker type. Then you have to draw them by your own.
It matters if you want the wireframe of the cube or filled patches.
See e.g. https://www.mathworks.com/matlabcentral/fileexchange/15161-plotcube or http://jialunliu.com/how-to-use-matlab-to-plot-3d-cubes/ (I magically found these links by asking an internet search engine for the terms "Matlab draw cube" - you can do this by your own also.)
8 Commenti
Jan
il 10 Dic 2017
@mr mo: The link in your former comment is dead now. For which function are you searching a legend? Did you try to provide one handle per legend entry? The plotcube command would need to add an output of the handles. But I would take this code as example only, how to call patch. E.g.:
side = 5;
verts = ([0 0 0;0 1 0;1 1 0;1 0 0;0 0 1;0 1 1;1 1 1;1 0 1] - 0.5) .* side;
face = [1 2 3 4;5 6 7 8;3 4 8 7;1 2 6 5;2 3 7 6;1 4 8 5];
h1 = patch('Faces',face,'Vertices',verts,'FaceColor','b', ...
'EdgeColor','w');
h2 = patch('Faces',face,'Vertices',verts + 8,'FaceColor','g', ...
'EdgeColor','k');
legend([h1, h2], {'1', '2'})
view(45, 30)
grid on
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Legend in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!