필터 지우기
필터 지우기

how to show datestring animation on a plot?

조회 수: 1 (최근 30일)
reddy
reddy 2015년 11월 5일
편집: per isakson 2016년 2월 9일
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
reddy
reddy 2015년 11월 17일
편집: per isakson 2016년 2월 9일
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 2016년 2월 9일
편집: per isakson 2016년 2월 9일
Did you try to replace
title(sprintf('Time: %d',timestr));
by
title(sprintf('Time: %s',timestr{:}));

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by