save graph in video
이전 댓글 표시
Hi all,
My supervisor gave me this code. I modified it to make it work like i wnated. However i would like at the end of the code to save the video that has been created. Does someone know how to do that?
Thank you for your help
jonathan
clear all
close all
clc
cd('D:\Raw_data\Surface\Autumn\Lat_lon\');
addpath C:\Matlab_download\m_map1.4f\
load ('October_01_2014_surface_lat_##.mat');
load ('October_01_2014_surface_lon_##.mat');
lat1 = lat(4187,:);
lon1 = lon(4187,:);
X=lon1;
Y=lat1;
%day = M(a,2);
%month = M(a,3);
%year = M(a,4);
%hour = M(a,5);
%mins = M(a,6);
LNMIN = -5.8;%horizontal
LNMAX = -2.5;
LTMIN = 52.7; %vertical
LTMAX = 55;
m_proj('utm','lon',[LNMIN,LNMAX],'lat',[LTMIN,LTMAX],'zone',30,'hem',0,'ell','wgs84');
%%
clf;
m_gshhs_f('patch',[.7 .7 .7],'edgecolor',[.2 .2 .2]),hold all
m_grid('linestyle','none','box','fancy','tickdir','in','fontsize',11,'Fontname','Times New Roman');
set(gca,'tickdir','out','fontweight','bold','fontsize',15,'Fontname','Times New Roman');
% time step 1:
h1 = m_plot(X(1),Y(1),'.-b');
hold on
h2 = m_plot(X(1),Y(1),'or');
h3 = m_plot(X(1),Y(1),'^','color',[0 0.6 0],'linewidth',2);
%title(datestr(datenum(year(1),month(1),day(1),hour(1),mins(1),0)));
for it=2:length(lat1)
lag = min([it,25]);
delete(h1);
delete(h2);
h1 = m_plot(X(it-lag+1:it),Y(it-lag+1:it),'.-b');
h2 = m_plot(X(it),Y(it),'or');
% work out date and display it....
%title(datestr(datenum(year(it),month(it),day(it),hour(it),mins(it),0)));
drawnow
pause(0.05)
end
답변 (2개)
Image Analyst
2021년 3월 17일
2 개 추천
You can use exportgraphics() to save figures or axes. If you want an example of how to draw something in an axes and change it and make a movie out of it, check out my simple attached example.
- Use F=getframe() to store an image of the plot for each iteration of the for-loop. Save F to file if you want to replay the movie without re-collecting the frames.
- Use movie(F,__) to play back the movie.
댓글 수: 5
Jonathan Demmer
2021년 3월 17일
Jonathan Demmer
2021년 3월 17일
Adam Danz
2021년 3월 17일
> Save F i add it inside the loop, right?
No. Check out the example in the link I shared. You only need to save F to file if you want to play it later.
> Undefined function 'Save' for input arguments of type 'char'.
save is not capitalized.
Jonathan Demmer
2021년 3월 17일
Adam Danz
2021년 3월 17일
You can use VideoWriter which is what ImageAnalyst is doing, I believe.
There's also a nice demo in the documentation,
카테고리
도움말 센터 및 File Exchange에서 Image Preview and Device Configuration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!