How do I change height and colour of cylinder made with SURF?
Mostrar comentarios más antiguos
[x,y,z]=cylinder(10);
surf(x,y,z)
the result came out is a blue cylinder with radius 10. how do i change the colour and height in this case?
Respuesta aceptada
Más respuestas (4)
Walter Roberson
el 27 de Mayo de 2011
0 votos
The simplest way to plot horizontally might be to change the viewpoint and relabel the axes :)
Otherwise you might need to create an hgtransform() that does a rotation and parent the surface to it using surf(x,y,z,'Parent',TheHGHandle)
Patrick Kalita
el 13 de Jul. de 2011
% Make the hgtransform and the surface; parent the surface to the hgtransform
[x,y,z] = cylinder(10);
h = hgtransform;
surf(x,y,z, 'Parent', h, 'FaceColor', 'r');
view(3)
% Make it taller
set(h, 'Matrix', makehgtform('scale', [1 1 10]))
% Tip it over and make it taller
set(h, 'Matrix', makehgtform('xrotate', pi/2, 'scale', [1 1 10]))
Álvaro Romero Calvo
el 7 de Oct. de 2018
Editada: Walter Roberson
el 11 de Oct. de 2018
0 votos
Here you can find an easy way ;)
Tomasz
el 7 de Nov. de 2021
0 votos

k=0:0.2:1;
[X,Y,Z]=cylinder(k,3);
figure
surf(X(1:2,:),Y(1:2,:),Z(1:2,:),'facecolor',[0,0,1])
hold on
surf(X(2:3,:),Y(2:3,:),Z(2:3,:),'facecolor',[0 ,0.4470, 0.7410])
surf(X(3:4,:),Y(3:4,:),Z(3:4,:),'facecolor',[0,1,1])
surf(X(4:5,:),Y(4:5,:),Z(4:5,:),'facecolor',[1,1,0])
surf(X(5:6,:),Y(5:6,:),Z(5:6,:),'facecolor',[1,0,0])
hold off
Categorías
Más información sobre Object Containers en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!