Rotating a cylinder by 90 degrees
63 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan Bird
am 22 Mär. 2018
Kommentiert: Julien Cotton
am 9 Feb. 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?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Mär. 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 Kommentar
Julien Cotton
am 9 Feb. 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(:)]';
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!