how to show datestring animation on a plot?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone,
I am trying to make a movie (I want to do title animation) from time series data...
as the days change I want to change the date accordingly on the plot..
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;close all;clc;clear memory;
%
h = ncread('D:\phanindra\New volume G\New folder\current data\nc\aviso\msla\all-sat-merged\h\2011_2014h.nc','sla',[305 377 1],[81 81 1457]);
%
l1 = ncread('D:\phanindra\New volume G\New folder\current data\nc\aviso\msla\all-sat-merged\h\2011_2014h.nc','lon');
%
l2 = ncread('D:\phanindra\New volume G\New folder\current data\nc\aviso\msla\all-sat-merged\h\2011_2014h.nc','lat');
%
[x y] = meshgrid(l1(305:385),l2(377:457));
%
u1 = ncread('D:\phanindra\New volume G\New folder\current data\nc\aviso\msla\all-sat-merged\uv\2011_2014_uv.nc','u',[305 377 1],[81 81 1457]);
%
v1 = ncread('D:\phanindra\New volume G\New folder\current data\nc\aviso\msla\all-sat-merged\uv\2011_2014_uv.nc','v',[305 377 1],[81 81 1457]);
%
start_time = datenum(2011,01,01);
end_time = datenum(2014,12,27);
inc = datenum(2012,01,02)-datenum(2012,01,01);
time = datestr([start_time:inc:end_time]);
t = cellstr(time);
for l=731:760;
sla=h(:,:,l);
lon=x;
lat=y;
us=u1(:,:,l);
vs=v1(:,:,l);
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
m_proj('miller','long',[80 92],'lat',[8 24]); % larger part of the bay
m_contourf(lon,lat,sla',20); colorbar; caxis([-0.25 0.25]);
hold on
m_quiver(lon,lat,us',vs',5,'color','k')
m_grid('box','fancy','tickdir','in');
m_coast('patch',[0 0 0]);
colormap(jet)
clear sla;
clear us; clear vs;
clear lon; clear lat
drawnow;
%print -dpng -r300 test.png
M(l)=getframe(gcf);clf;
end
I am getting error like "text command not compatible with cell data.." and also my animation technique also not good..
help me out with this.
thanks in advance..
3 Kommentare
per isakson
am 9 Feb. 2016
Bearbeitet: per isakson
am 9 Feb. 2016
Did you try to replace
title(sprintf('Time: %d',timestr));
by
title(sprintf('Time: %s',timestr{:}));
Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!