problem with Solid of revolution

Hello,
I have a 2D function as shown in the curve below
, which I would like to revolve around x-axis using cylinder.
[X,Y,Z]=cylinder(y);
figure;surf(X,Y,Z);
xlabel('x');ylabel('y');zlabel('z');
So for the generated solid, x range should be 24-122 and both y and z axis range should be 0-~40. But I an getting something like the below solid.
I don't get why both x and y- axis ranges are the same and why z is varying from 0-1. What am I doing wrong? Ideally I should get an oval shaped solid and no sharp peak.
Thank you for the help.

 採用された回答

Star Strider
Star Strider 2016 年 12 月 20 日

0 投票

That’s the default behaviour of the cylinder function. Use the rotate function to tip your customised cylinder on its side, and oriented in the direction you want.

5 件のコメント

sumana
sumana 2016 年 12 月 20 日
Hello,
I don't get it. The rotate function (https://www.mathworks.com/help/matlab/ref/rotate.html) is simply rotating a surface. How is it related to generation of solid of revolution ? Could you please provide an example ? I need to create a solid of revolution with that function around x-axis.
Thank you
Star Strider
Star Strider 2016 年 12 月 20 日
Experiment with the rotate function and you will get it. The documentation illustrates using it on a specific function in order to illustrate the concept. It works on cylinder objects as well, since they’re all surf plots.
Here’s an example of tilting a cylinder on its side:
[X,Y,Z] = cylinder(50);
figure(1)
cyl = surf(X,Y,Z*100);
rotate(cyl, [0 1 0], 90)
axis equal
sumana
sumana 2016 年 12 月 20 日
Thanks, but the solid that I obtained is incorrect, I can rotate any solid using rotate(), but I am not getting the correct solid of revolution. There is something wrong with the generated solid, it should not have sharp ends. How do I get the correct solid of revolution whose both ends are flat not sharp ?
sumana
sumana 2016 年 12 月 20 日
Ok, I think I got it. It is drawing the cylinder using just the y values taking them as a radius, it is not considering the x values while drawing the cylinder. ok thanks
Star Strider
Star Strider 2016 年 12 月 20 日
My pleasure.
The axis aspect ratio controls how the plot looks. See the documentation for the axis function for details. Setting them to square or equal will change the appearance of the plot.
You can rotate the cylinder using any combination of the axes in the vector and at any angle.
If my Answer helped solve your problem, please Accept it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2016 年 12 月 20 日

コメント済み:

2016 年 12 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by