clc;clear all;close all;
h=animatedline('LineStyle',':','Color','b','Marker','o','Markersize',2,'MarkerEdgecolor',[1 0 1],'MarkerFaceColor','k');%创建一根没有任何数据的动画线条并将其添加到当前坐标区中
format shortg;%调整数据格式
x=linspace(1,10,100);
set(gca,'XLim',[0 10]);%设置坐标轴范围
avi=VideoWriter('懒羊羊.avi');%创建对象
avi.FrameRate=2;%播放帧
open(avi);
for i=1:1:length(x)
title('e^x');
addpoints(h,x(i),exp(x(i)));
f = getframe(gcf);%截取窗口的图片
writeVideo(avi,f);%写入视频
drawnow
end
close(avi);%关闭文件
drawnow ;%循环结束后调用drawnow在屏幕上显示最终更新。