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

#plot3 #3d graph

>> 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?

Best Answer

  • 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)))