520快到了,教你用matlab製作動態心形曲線表白(保存爲AVI視頻版本)

前面用matlab製作了gif的動態心形曲線:matlab製作動態心形曲線(保存爲gif版本)

% matlab動態心形曲線(AVI視頻版本)
clc;clear all;
a=0;
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:200
    str_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*(π-x^2)^1^/^2*sin(a*π*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);

效果如下:

[video(video-wGTrViQY-1589545478946)(type-bilibili)(url-https://player.bilibili.com/player.html?aid=200678652)(image-https://ss.csdn.net/p?http://i0.hdslb.com/bfs/archive/6e13ff0e324e1c295c9a71c67a9c1dbd1ec0bbc5.jpg)(title-心形圖)]

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章