Plotting help, my graph turns very clunky

1 回表示 (過去 30 日間)
Japoe25
Japoe25 2015 年 4 月 27 日
コメント済み: Japoe25 2015 年 4 月 27 日
I'm trying to recreate the image attached of a elliptical spiral staircase but it's not working out too well. Please help!
function z = my_staircase(a,b,h,n)
tv = 0:2*pi*n;
for k1 = 1:length(tv)
t = tv(k1);
r=((a*b)*exp(-.04*t))/sqrt((b*cos(t)^2)+ (a*sin(t))^2);
x(k1)=r*cos(t);
y(k1)=r*sin(t);
z(k1)=(h*t)/(2*pi*n);
end
hold on
plot3(x,y,z)
xlabel('x(m)'); ylabel('y(m)');zlabel('z(m)');
grid on
view([-30 30])
end
The graph I got was for my_staircase(20,10,100,7) :
%

回答 (1 件)

Mischa Kim
Mischa Kim 2015 年 4 月 27 日
編集済み: Mischa Kim 2015 年 4 月 27 日
Japoe25, just add more data points. E.g.,
tv = 0:0.1:2*pi*n; % 0.1 is the spacing between data points
  1 件のコメント
Japoe25
Japoe25 2015 年 4 月 27 日
It's still pretty clunky even with 0.001

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by