欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

螺旋线的画法---matlab代码

程序员文章站 2022-06-07 14:42:19
...
clearvars;
close all;
clc;
%每个圆的周长是一样的
t = 0:0.01:4*pi;
x = cos(t);
y = sin(t);
z = t*2;
figure;
plot3(x,y,z,'r-');
hold on;
plot3(x,-y,z,'b')
title('螺旋线');
xlabel('x axis');
ylabel('y axis');
zlabel('z axis');
grid on;

螺旋线的画法---matlab代码

clearvars;
close all;
clc;
%每个圆的周长是一样的
t = 0:0.01:4*pi;
x = cos(t);
y = sin(t);
z = t*2;
figure;
plot3(x,y,z);
title('螺旋线');
xlabel('x axis');
ylabel('y axis');
zlabel('z axis');
grid on;

螺旋线的画法---matlab代码

%圆的周长是递增的
t = 0:0.01:10*pi;
A = 1;
w = 1;
sita = 0;
for ii = 1:length(t)
    x(ii) = A *cos(w*t(ii) + sita);
    y(ii) = A *sin(w*t(ii) + sita);
    A = A+ 0.1;
end
z = t*2;
figure;
plot3(x,y,z,'r');
title('螺旋线');
xlabel('x axis');
ylabel('y axis');
zlabel('z axis');
grid on;

螺旋线的画法---matlab代码

相关标签: matlab 螺旋线