Plotting 3D parameterised curve help

1 回表示 (過去 30 日間)
Jenny Briggs
Jenny Briggs 2016 年 3 月 14 日
編集済み: Star Strider 2016 年 3 月 14 日
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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by