%% f(t)-->f(4*t+12) 并且验证%%function Signal_change()tic%记录程序运行时间figuren = 0;t = -2*pi:0.01:2*pi;y = sin(t);%周期为2*piy_result = sin(4*t);plot(t,y,'b');xlabel('t');ylabel('Amplitude');n = n+1;F(n) = getframe(gcf);%获取当前图形并且保存到F(n)中%saveas(gcf,['C:/Users/Administrator/Desktop/图片/',num2str(n),'.jpg']);hold on%% 验证%%%f(4*t+12) = f[4*(t + 3)].遵循先外后里原则具体的图形变换实现为:%1 、先将f(t)压缩4倍%2、再将压缩的图形左移3个单位。y_now = sin(t);h = plot(t,y_now,'--','YDatasource','y_now'); %% f(t)-->f(4*t)%%for i = 1:0.1:4y_now = sin(i*t);refreshdata(h,'caller');drawnow;n = n+1;F(n) = getframe(gcf);%saveas(gcf,['C:/Users/Administrator/Desktop/图片/',num2str(n),'.jpg']);pause(0.01);end%保留f(4*t)的图形n = n+1;plot(t,y_result,'r');F(n) = getframe(gcf);%saveas(gcf,['C:/Users/Administrator/Desktop/图片/',num2str(n),'.jpg']);hold on%% f(4*t)-->f(4*t+12)%%for j = 0:0.1:3y_now = sin(4*(t + j));refreshdata(h,'caller');drawnow;n =n+1;pause(0.1);legend('sin(t)','sin(4t+12)','sin(4t)');F(n) = getframe(gcf);%saveas(gcf,['C:/Users/Administrator/Desktop/图片/',num2str(n),'.jpg']);endmovie(F);%生成视频movie2avi(F,'imovie1.avi','FPS',3);%设置视频的帧率为3,数值越大速度越快
function Avi()%%大小写非常重要%% n = 64;WriterObj = VideoWriter('wmw');WriterObj.FrameRate = 100;%此语句必须放置在%WriterObj = VideoWriter('wmw')语句之后才能设置帧率open(WriterObj);for i=1:n%逐次取出文件frame=imread(['C:/Users/Administrator/Desktop/图片/',num2str(i),'.jpg']); %读取文件writeVideo(WriterObj,frame);end close(WriterObj);
以上所述是小编给大家介绍的Matlab制作视频并转换成gif动态图的两种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对VEVB武林网网站的支持!