用matlab画图

求星形线,心形线,对数螺线 .....的代码!!! 请大神给多点常见的二维,三维图的代码!!

这么多:
星形线:
clear all;clc;
a=2;
theta=0:pi/40:2*pi;
x=a*cos(theta).^3;
y=a*sin(theta).^3;
plot(x,y);
axis equal;
--------------------------------
心形线:
clear all;clc;
ezplot('x^2+y^2+3*x-3*sqrt(x^2+y^2)');
axis equal;
或:
clear all;clc;
a=3;
theta=0:pi/40:2*pi;
r=a*(1-cos(theta));
polar(theta,r);
------------------------
对数螺线:
clear all;clc;
a=1/10;
theta=0:pi/20:6*pi;
r=exp(a*theta);
polar(theta,r);追问

谢谢!能不能解释下theta=0:pi/40:2*pi;这句.... :pi/这些不懂。谢谢!

追答

theta=0:pi/40:2*pi

定义自变量,matlab要画图或计算,都要定义变量
theta从0开始取值,每隔pi/40取一个点,直到2*pi
当然你也可以自己另行定义,比如:
t=linspace(0,2*pi,50)
t=0:0.01:2*pi

温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-05-08