%VIDEO TITLE

%Save the figure with all relevant results
% savefig(fig,'figure-sim_1.fig')

v = VideoWriter('video-sim_1.avi','Uncompressed AVI'); %creates an object that is 
%used to write a video. Change the name to make sure that you don't
%overwrite on the previous recorded video.
 
%OPTION 1 - VIDEO WITH ALL FRAMES (for short simulations)

% Uncomment if you want to record the video
open(v); %opens the pre-define video object
writeVideo(v,F2); %write the video in the object v using the stored frames in the F2 matrix
close(v); %close the object. you can find it in your folder.

% OPTION 2 - VIDEO WITH A REDUCED NUMBER OF FRAMES (for long simulations)

% F3 = F2(2:2:end)
% open(v); %opens the pre-define video object
% writeVideo(v,F3); %wrtie the video in the object v using the stored frames in the F3 matrix
% close(v); %close the object. you can find it in your folder.