From: sumeho on
The Help document doesn't seem to be much help. My code has a small
time step to avoid instability and therefore has a high end time. It
takes entirely too long to run it with getframe and often results in
out of memory. I have many loops within my code and the help
documentation is not clear in how to apply it. I have summarized my
code below and put my last trial for saving the animation without
printing to screen. Would really appreciate any ideas or comments!

dt = 0.1; % seconds
end_time = 50000;
end_j = end_time/dt;
imax = 51; % set maximum number of index values
nframes = 100;
framespacing = end_j/nframes; %conditional for taking frames

%Initial conditions
for i=1:imax % initial values; create vectors
.....
end
V = 0; %movie frame counter
for j = 1:end_time
time(j) = j*dt; %updates the time elapsed
.....
for i = 2:imax-1
.....
end

%SAVE MOVIE-- trial 3.30.2010
hf = figure('visible','off'); % figure visibility off
aviobj = avifile('test14.avi','compression','None');
%set(gca,'xlim',[-1,imax],'ylim',[0,1]);
hax = axes;
for k = 1:nframes
hf = plot(x,eta,x,zold,'parent',hax);
%set(ht,['time is ' num2str(time(j)) ' seconds']);
aviobj = addframe(aviobj,hf);
end
%close(hf); %closes handle to invisible figure
aviobj = close(aviobj);

end % ends time loop