Plotting 3D parameterised curve help

1 次查看(过去 30 天)
I want to plot the curve:
r(r, θ) = (rcos(θ), rsin(θ), θ), 0 ≤ r ≤ 1, 0 ≤ θ ≤ 2π.
But I'm not really sure how to go about it.
I have tried this:
r = linspace(0,1);
theta = linspace (0,2.*pi);
x = r*cos(theta);
y = r*sin(theta);
z = theta;
plot(x,y,z)
However it keeps resulting in error.
Any help would be greatly appreciated, thanks

回答(1 个)

Star Strider
Star Strider 2016-3-14
编辑:Star Strider 2016-3-14
Since ‘r’ and ‘theta’ have the same number of elements (by default 100 with linspace), you can use element-wise multiplication:
r = linspace(0,1);
theta = linspace (0,2*pi);
x = r.*cos(theta);
y = r.*sin(theta);
z = theta;
figure(1)
plot3(x, y, z)
grid on
That should do what you want (plot an Archimedes spiral).

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by