Effacer les filtres
Effacer les filtres

Rotating a cylinder by 90 degrees

24 vues (au cours des 30 derniers jours)
Jonathan Bird
Jonathan Bird le 22 Mar 2018
Commenté : Julien Cotton le 9 Fév 2021
I've generated a cylinder as follows: [x,y,z]=cylinder([0,10,10,0],100);
z([1,2],:)=0;
z([3,4],:)=100;
mesh(x,y,z)
axis equal; I want to have the cylinder lying flat i.e. a rotation by 90d degrees. I've tried using the rotate function but couldn't get it to work, any suggestions?

Réponse acceptée

Star Strider
Star Strider le 23 Mar 2018
I don’t understand what your problem with rotate is.
Try these:
[x,y,z]=cylinder([0,10,10,0],100);
z([1,2],:)=0;
z([3,4],:)=100;
figure(1)
hm = mesh(x,y,z);
rotate(hm, [1 0 0], 90)
axis equal
figure(2)
hm = mesh(x,y,z);
rotate(hm, [0 1 0], 90)
axis equal
figure(3)
hm = mesh(x,y,z);
rotate(hm, [1 1 0], 45)
axis equal
  1 commentaire
Julien Cotton
Julien Cotton le 9 Fév 2021
Those lines do not work for me : get the following error :
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in rotate (line 49)
tmp =r*[x(:) y(:)]';

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by