Plotting 3D parameterised curve help
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Star Strider
on 14 Mar 2016
Edited: Star Strider
on 14 Mar 2016
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).
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!