how to show datestring animation on a plot?

2 visualizaciones (últimos 30 días)
reddy
reddy el 5 de Nov. de 2015
Editada: per isakson el 9 de Feb. de 2016
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 comentarios
reddy
reddy el 17 de Nov. de 2015
Editada: per isakson el 9 de Feb. de 2016
hi Walter,
it seems there is some missing commands and script in the script file.. Sorry for the delay reply also..
the error is
Error using sprintf
Function is not defined for 'cell' inputs.
Error in saving_multiple_plots (line 74)
title(sprintf('Time: %d',timestr));
I have tried and surfed to change the date string cell data to array.. I couldn't get any source. for easier way I am attaching the mfile. please find the attachment.Thanks for reply.
per isakson
per isakson el 9 de Feb. de 2016
Editada: per isakson el 9 de Feb. de 2016
Did you try to replace
title(sprintf('Time: %d',timestr));
by
title(sprintf('Time: %s',timestr{:}));

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by