I want to create a helix sprial. I wish to have control over changing the radius of the spiral, the gap between each layer and the height of the spiral. How would I do that?
I obtained the code below from MATLAB's Documentation however I am not familiar with it. If you can explain how st and ct works that would be helpful too.
Thanks in advance
clc; clear; close all
t = 0:pi/50:10*pi;
st = sin(t);
ct = cos(t);
plot3(st,ct,t)
grid on

 采纳的回答

Bruno Luong
Bruno Luong 2019-8-19
编辑:Bruno Luong 2019-8-19
r = ...
gap = ...
t = (2*pi/gap)*(0:0.001:10);
st = r*sin(t);
ct = r*cos(t);

5 个评论

Thanks for the quick answer, Bruno. Appreciate it
However I am still confused over the how to change the height of the spiral (black) vs. changing the layer height (blue). Hope the image below helps you understand my problem
Plot3DHelixExample_01.png
For
t = (2*pi/gap)*(0:0.001:10)
The blue distance is "gap"
The black distance is 2*pi*10/gap
If I want to make the height (black line) be independent of the gap, how would I change the code?
Because I have 3 user requested variables - Radius, Gap, Height
Thanks for the reply
gap=5 % blue distance
d=30 % black distance
r = 2;
z=linspace(0,d,1000);
t=(2*pi/gap)*z;
x=r*cos(t)
y=r*sin(t)
plot3(x,y,z)
works exactly as I want it to, thank you for the help!

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by