Skip to content

Instantly share code, notes, and snippets.

@AmeliaMN
Created October 22, 2012 18:21
Show Gist options
  • Save AmeliaMN/3933144 to your computer and use it in GitHub Desktop.
Save AmeliaMN/3933144 to your computer and use it in GitHub Desktop.
Matlab example: Creating a movie of ODE results
function M = longmovie2(Yfile,Tfile,x,y,n)
dbstop if error
dbstop if naninf
dbstop if warning
fid1=fopen(Yfile,'r');
fid2=fopen(Tfile,'r');
T=fread(fid2,inf,'double');
T=T.';
h = figure;
step=floor(length(T)/(T(end)*8));
st=floor(length(T)/T(end));
set(h,'NextPlot','replacechildren');
index=1;
for i = 1:step:(length(T)-1)
offset=(st*16*n^2);
u1=fread(fid1,[n,n],'double');
v1=fread(fid1,[n,n],'double');
u2=fread(fid1,[n,n],'double');
v2=fread(fid1,[n,n],'double');
figure(h);
h2=surf(x,y,v1);
axis([min(x) max(x) min(y) max(y)])
set(h2,'EdgeColor','none');
view([0 90]);
colormap(gray);
drawnow;
M(index)=getframe;
index=index+1;
end
fclose('all');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment