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
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.

댓글 수: 1

Jonathan Demmer
Jonathan Demmer 2021년 3월 17일
Wow!! That is amazing!! Thank you so much!!!

댓글을 달려면 로그인하십시오.

Adam Danz
Adam Danz 2021년 3월 16일
편집: Adam Danz 2021년 3월 17일

0 개 추천

  1. 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.
  2. Use movie(F,__) to play back the movie.
See Method 3: Create a movie for a demo.

댓글 수: 5

Jonathan Demmer
Jonathan Demmer 2021년 3월 17일
Thank you fro your answer.
Save F i add it inside the loop, right?
Hi,
I added in the loop
F = getframe;
Save F;
and this error appeared:
Undefined function 'Save' for input arguments of type 'char'.
Error in Video_aquaculture (line 79)
Save F;
Would you mind to explain me what happened please?
Adam Danz
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
Jonathan Demmer 2021년 3월 17일
Ok it works!! tahnk yo uvery much!! However it saves F into a matrix, would it be possible to save it as a video (.avi)?
Adam Danz
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,

댓글을 달려면 로그인하십시오.

태그

질문:

2021년 3월 16일

댓글:

2021년 3월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by