曲线avi
clear;clc;
a=20;
x=-2:0.01:2;
writerObj=VideoWriter('心,avi');
writerObj,FrameRate=20;
open(writerObj);
figure(1);
set(gcf,'position',[0,0,800,600],'color','w');
for i=1:200str_title=strcat('\color{red}a=',num2str(a));y=abs(x).^(2/3)+(0.9*sqrt(3.3-x.^2)).*sin(a*pi*x);a=i/10;figure(i);
set(gcf,'position',[0,0,800,600],'color','w');
p1=plot(x,y,'r','LineWidth',3);hold on;
title('\color{red}f(x)=x^2^/^3+e/3*(pi-x^2)^1^/^2*sin(a*pi*x)','fontsize',15);
text(-0.2,2,3,str_title,'FontName','Times New Roman','FontSize',20);
xlim([-2 2]);
ylim([-1.5 2.5]);
frame = getframe(gcf);writeVideo(writerObj,frame);close(figure(i));clf;
end;
%close(writerObj);
曲线gif
clear;clc;
a=20;
x=-2:0.01:2;figure(1);
set(gcf,'position',[0,0,800,600],'color','w');
for i=1:200str_title=strcat('\color{red}a=',num2str(a));y=abs(x).^(2/3)+(0.9*sqrt(3.3-x.^2)).*sin(a*pi*x);a=i/10;figure(i);
set(gcf,'position',[0,0,800,600],'color','w');
p1=plot(x,y,'r','LineWidth',3);hold on;
title('\color{red}f(x)=x^2^/^3+e/3*(pi-x^2)^1^/^2*sin(a*pi*x)','fontsize',15);
text(-0.2,2,3,str_title,'FontName','Times New Roman','FontSize',20);
xlim([-2 2]);
ylim([-1.5 2.5]);
frame=getframe(gcf);im=frame2im(frame);
[I,map]=rgb2ind(im,256);
if i==1imwrite(I,map,'心.gif','gif','Loopcount',Inf,'DelayTime',0.05);
elseimwrite(I,map,'心.gif','gif','WriteMode','append','DelayTime',0.05);
end
close(figure(i));
end
xin 1
[x,y,z]=meshgrid(-1.5:0.01:1.5);
f=(x.^2+(9/4)*y.^2+z.^2-1).^3-x.^2.*z.^3-(9/80)*y.^2.*z.^3;
heart=patch(isosurface(x,y,z,f,0));
axis equal;view(3);
set(heart,'FaceColor', 'r', 'EdgeColor', 'none');
camlight;
xin 2
f=@(x,y,z)(x.^2+ (9./4).*y.^2 + z.^2 - 1).^3 - x.^2.*z.^3 - (9./80).*y.^2.*z.^3;
[x,y,z]=meshgrid(linspace(-3,3));
val=f(x,y,z);
[p,v]=isosurface(x,y,z,val,0);
patch('faces',p,'vertices',v,'facevertexcdata',jet(size(v,1)),'facecolor','w','edgecolor','flat');
view(3);
grid on;
axis equal;
xlabel('MATLAB万岁')
ylabel('数学建模')
zlabel('相信自己')
title('证明自己')
% xlabel('lim me→∞=you')
% ylabel('I=q/t')
% zlabel('9/3')
% title('128√e980')
text(1.2,0,0,'Just for you!','FontSize',14)
xin 3
[x,y,z]=meshgrid(-1.5:0.01:1.5);
f=(x.^2+ (9./4).*y.^2 + z.^2 - 1).^3 - x.^2.*z.^3 - (9./80).*y.^2.*z.^3;
heart=patch(isosurface(x,y,z,f,0));
axis equal;view(3);
set(heart,'FaceColor', 'r', 'EdgeColor', 'none');
camlight('right')
camlight('left')
camlight('headlight')
lighting phong
xlabel('MATLAB万岁')
ylabel('数学建模')
zlabel('相信自己')
title('证明自己')
text(1.2,0,0,'Just for you!','FontSize',14)
xin xing hua tu
%参考:一只小小鸟儿htts://ww. bilibili. com/video/BV15b4y1878R?from-searchlseid=1 1968608030526306371&spm_ id. from-333. 337. 0.0
clear all
clc
f = @(x,a)real (abs(x).^(2/3) + exp(1)/3. *(pi -x.^2).^0.5.* sin(a*pi.* x)) ;%隐函数
x=- 2:0.01:2;
for a = 0:0.5:40y = f(x,a);plot(x,y,'r','LineWidth' ,2) %本质上是图片不断被替换axis([-2 2 -1.5 2.5]);
pause(0.1) %程序暂停0.1秒
end
xin ji zuo biao
theta=-pi:0.001:pi;r=1-sin(theta);polar(theta,r,'r');