Circumference and cone in plot3

Hello everyone!
How I represent a circumference in a figure of Plot3? (i have the coordinates x,y and z of center and radius).
By the way...how i represent a cone beginning in center of circumference (x,y,z of center)?
Thanks!!

回答 (1 件)

Star Strider
Star Strider 2015 年 5 月 9 日

1 投票

See the documentation for the sphere and cylinder functions. You can define the radius of the cylinder as a function of z.
For instance:
r = 0:0.1:1; % Define Radius Of Cone
[X,Y,Z] = cylinder(r);
figure(1)
surf(X, Y, Z)
axis square

5 件のコメント

Nuno
Nuno 2015 年 5 月 9 日
for example, to the circumference
hold on
r=9;
x=198;
y=145;
z=210;
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
zunit= r*sin(th)+z; % I'm not sure it
h = plot3(xunit, yunit,zunit);
is correct?
Star Strider
Star Strider 2015 年 5 月 9 日
If that is what you want, then it’s correct. It plots the circumference of a circle on an inclined plane.
The cone is easy:
% CONE USING ‘plot3’
z = linspace(0, 100, 1000);
x = z.*cos(z*pi);
y = z.*sin(z*pi);
figure(1)
plot3(x, y, z)
grid on
axis equal
Nuno
Nuno 2015 年 5 月 9 日
Yeah, it s work!! :D
But if i want that cone begin in one specific point? i change linspace line?
Nuno
Nuno 2015 年 5 月 9 日
x0=170;
y0=186;
z0=210;
hold on
[x,y,z] = sphere;
surf(x+x0,y+y0,z+z0)
how i put the radius?
Star Strider
Star Strider 2015 年 5 月 9 日
I am not sure what you want to do. You are of course free to experiment by changing the linspace parameters as you wish. If you want to shift the apex of the cone from (0,0), add those values to ‘x’ and ‘y’.
So to shift it to (10,10), do this:
z = linspace(0, 100, 1000);
x = z.*cos(z*pi)+10;
y = z.*sin(z*pi)+10;
figure(1)
plot3(x, y, z)
grid on
axis equal

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

カテゴリ

タグ

質問済み:

2015 年 5 月 9 日

コメント済み:

2015 年 5 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by