What is problem to make space curve [2*cos(t),2*sin(t),5]?

1 view (last 30 days)
>> t = 0:pi/10:pi;
>> plot3(2*cos(t),2*sin(t),5)
Error occurred while using: plot3
Vectors should be the same length.
What should I do?

Accepted Answer

Steven Lord
Steven Lord on 1 Jun 2020
You want to draw this curve in the section of 3-d space in the plane z = 5? You need to specify one z coordinate for each coordinate in x and y. plot3 doesn't do scalar expansion like many other functions do.
>> t = 0:pi/10:pi;
>> plot3(2*cos(t),2*sin(t),repmat(5, size(t)))

More Answers (1)

Image Analyst
Image Analyst on 1 Jun 2020
Not sure what the 5 is for, but maybe you mean this, using plot3() to plot a 3-D curve:
t = 0 : pi/10 : pi;
plot3(t, 2*cos(t),2*sin(t), 'b.-', 'LineWidth', 2, 'MarkerSize', 20)
grid on;
xlabel('t', 'FontSize', 15);
ylabel('y', 'FontSize', 15);
zlabel('z', 'FontSize', 15);
or maybe you mean this, using plot() to plot a 2-D curve:
t = 0 : pi/10 : pi;
plot(2*cos(t),2*sin(t), 'b.-', 'LineWidth', 2, 'MarkerSize', 20)
grid on;
xlabel('t', 'FontSize', 15);
ylabel('y', 'FontSize', 15);

Categories

Find more on 2-D and 3-D Plots 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!