I am working to create a helix in Matlab.
Going by the below code:
t = 0:pi/50:20*pi;
(Can you please explain me this syntax or we have to follow this everytime when creating a helix?)
st = sin(t);
ct = cos(t);
plot3(st,ct,t)
As maximum efficiency in a helix angle is between 40 and 45 degrees, if I want to enter the angle as 42, how is it possible in the code?
It would be very helpful if anyone can share their opinion on this
TIA
What happens in the code is merely an execution of the parametric mathematical description of a helix, which you can read up on wikipedia as
x(t) = cos(t)
y(t) = sin(t)
z(t) = t
The first line of your code generates a vector for values of t
from 0 to 20pi
in steps of pi/50
(i.e., 1000 steps). Since every 2pi
means one full rotation (cos and sin are 2pi-periodic), it coincides to 10 turns of the helix (if you want to change this, let t
run up to 2*pi*NumberOfRotations
). The other two lines generate corresponding vectors for x
and y
. plot3 plots a line in 3-D where x
and y
are passed and as argument for z
we pass t
since z=t
.
To change the slope of the helix, use the more general description given by
x(t) = a*cos(t)
y(t) = a*sin(t)
z(t) = b*t
where a is the radius and b/a is the slope. To get 42° use b = a*atand(42)
. To make sure the aspect ratio is correct in display, use axis equal;
after the plot and maybe axis vis3d;
if you want to turn it around.