First you have to make frames (images) of each time step of your simulation.
Since you have Cartesian coordinates, you have to convert your x and y coordinates to pixel indices, and make an image matrix from them. See my answer to a relevant question for an example of how to do this. You could also modify the code to make your points larger than a pixel, have shapes, etc., perhaps with strel
or [a,b,~] = sphere(N)
.
Once you have the frames, you can easily make an AVI file (uncompressed or MPEG) in MATLAB:
aviOutput = fullfile('path','to','file.avi');
aviobj = VideoWriter(aviOutput);
aviobj.Quality = 100;
aviobj.FrameRate = 24; %# arbitrary
open(aviobj);
for i=1:length(frames)
writeVideo(aviobj,frames{i}); %# or frames(:,:,i) etc.
end
close(aviobj);
Update
The above assumes the time steps are all available. For example:
files = dir('path/to/dir');
files(1:2) = []; %# . and ..
orderedfiles = cell(length(files),1);
for i=1:length(files)
ind = sscanf(files(i).name,[name '%*[_]%u%*s']);
orderedfiles{ind+1} = files(i).name;
end
timeSteps = zeros(numPoints,2,length(orderedfiles));
for i=1:length(orderedfiles)
temp = load(orderedfiles(i).name);
timeSteps(:,:,i) = temp.matrixName %# All the same name?
end
The code from the linked answer is written to operate on two vectors x
and y
with the coordinates, which you would get with timeSteps(:,1,i)
and timeSteps(:,2,i)
, and do for each time step.