Matlab 3d grid and line drawing

I need help building a spiral spiral on a cone. For spiral:

x = tsin(6t)
y = tcos(6t)
z = t/3

... and this spiral lies on a cone:

z = sqrt(x^2+y^2)/3

I need to plot a cone grid graph and a three-dimensional graph of a spiral line on the same graph.

+5
source share
1 answer

I think that first you want to get a surface graph of the cone. Try

[X Y] = meshgrid(-1:.01:1);
Z = sqrt(X.^2 + Y.^2)/3;

Then draw this surface using the function surfand set some shading and transparency.

surf(X,Y,Z), caxis([-1 1]), shading flat, alpha(.5);

This should make the shape of a cone (you can play with flowers).

Now define the vectors for the spiral, as you did

t = 0:.01:1;
x = t.*cos(6*t);
y = t.*sin(6*t);
z = t/3;

Then do

hold on;

This makes it so that any other graph is displayed in the same figure.

Then finally

plot3(x,y,z);
+7
source

All Articles