**我想出了如何创建电影,以便代码已更改为反映正确的电影,以防将来对任何人有用。 此脚本创建eqdconic地图的电影并将其保存为avi格式。电影将贯穿1255帧。它还在图像上的某个点绘制一个点,在电影上放置一个改变的标题,以显示月份的运行情况,并在右侧显示一个颜色条。MATLAB创建电影
一些使用的变量是在别处创建的。创建它们的代码已被排除在外以压缩代码(并且因为它们不会对除我以外的任何其他人有用)。
% Create movie
nFrames = 34; % Number of frames
for k = 1:nFrames
% Eqdconic script
% Define figure and axes
fg1 = figure(1);
axesm('MapProjection','eqdconic', 'MapParallels', [], 'MapLatLimit',[-80 -59],'MapLonLimit',[190 251]) % 60-70S and 120-160W
framem on; gridm on; mlabel on; plabel on; hold all;
% Plot data
frame = dataPoint_movie(:,:,k);
image = contourfm(lat,lon,frame, 'LineStyle', 'none');
hold on
% Plot dot
plotm(-66.75,224,'k.','MarkerSize',30);
% Colorbar
caxis([0 100]);
h = colorbar;
ylabel(h,'Percent');
% Title: Days 1:1258 inclusive. 20100101 to 20130611
date = datenum(2009, 12, 31) + k; % Convert t into serial numbers
str = datestr(date, 'mmm yyyy'); % Show in the format mmm yyyy so title changes only once a month
title(str);
mov(k) = getframe(gcf); % gca would give only the image. gcf places the title and other attributes on the movie.
end
close(gcf)
% % Save as AVI file
movie2avi(mov, 'SeaIceConcentration.avi', 'compression', 'none', 'fps', 2);
'for t = 1:12'-loop生成一个图还是空轴? – Schorsch
基于['getframe'-documentation](http://www.mathworks.com/help/matlab/ref/getframe.html),你是否试过'A(i)'而不是'A(:,:我)'? – Schorsch
为什么从'i = 1:numframes'循环,然后从't = 1:1258'再次循环每个'i'? – Schorsch