save graph in video
21 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (2)
Image Analyst
il 17 Mar 2021
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.
Adam Danz
il 16 Mar 2021
Modificato: Adam Danz
il 17 Mar 2021
- 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 Commenti
Adam Danz
il 17 Mar 2021
You can use VideoWriter which is what ImageAnalyst is doing, I believe.
There's also a nice demo in the documentation,
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!