matlab心形动态图代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
matlab心形动态图代码clc;
h1=figure('name','I love you'); axis([-1.5 1.5 -2 0.5]);axis off; set(gcf,'color','black');
n=4;
a=320;
m=10^(-a);
hll=line(NaN,NaN,'marker','.','linesty','-
','erasemode','none','color','r');
x1=[];
y1=[];
for theta=pi/2:-2*pi/999:-3*pi/2 r1=1+cos(theta+pi/2);
x1=[x1;r1*cos(theta)];
y1=[y1;r1*sin(theta)];
set(hll,'xdata',x1,'ydata',y1); pause(m);
end
pause(1);
fill(x1,y1,'r');
axis off;
set(gcf,'color','black');
text(-0.16*n,-0.85,'XX','fontsize',n*18,'color','b');
title('Love','fontsize',18,'color','m');
disp('love you ');
pause(1);
x2=[];
y2=[];
h22=line(NaN,NaN,'marker','.','linesty','-
','erasemode','none','color','b');
for theta=pi/2:-2*pi/999:-3*pi/2; r2=1+cos(theta+pi/2);
x2=[x2;r2*cos(theta)];
y2=[y2;r2*sin(theta)];
set(h22,'xdata',x2,'ydata',y2); pause(m^19);
end
h2=figure('name','I love you'); fill(x2,y2,'r');
text(-0.58,-0.7,'我爱你','fontsize',40,'color','b'); text(-0.17,- 1.1,'XX','fontsize',18,'color','m'); axis off;
set(gcf,'color','black');
pause(1);
x3=[];
y3=[];
h33=line(NaN,NaN,'marker','.','linesty','-
','erasemode','none','color','b');
for theta=pi/2:-2*pi/999:-3*pi/2 r3=1+cos(theta+pi/2); x3=[x3;r3*cos(theta)];
y3=[y3;r3*sin(theta)];
set(h33,'xdata',x3,'ydata',y3); pause(m^19);
end