Rotating a cylinder by 90 degrees

62 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2018-3-23
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 个评论
Julien Cotton
Julien Cotton 2021-2-9
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(:)]';

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by