Matlab绘制动态心形线

1. 代码

for alpha=0:0.1:30
x=-1.8:0.001:1.8;
y=(x.^2).^(1/3)+0.9*(3.3-x.^2).^(1/2).*sin(alpha*pi*x);
plot(x,y,'r-','LineWidth',1.2);
set(gca,'YGrid','on');
axis([-3,3,-2,4]);
text(-2,3.35,'$f(x)=x^{\frac{2}{3}}+0.9(3.3-x^2)^{\frac{1}{2}}sin(\alpha\pi x)$','Interpreter','latex','Fontsize',15);
str_alpha=['$\alpha=',num2str(alpha),'$'];
text(-0.4,2.8,str_alpha,'Interpreter','latex','Fontsize',15);
pause(0.03);
end

2. 效果

Matlab绘制动态心形线_第1张图片

你可能感兴趣的:(Matlab,matlab)