MATLAB Recipes


Here I collect a few MATLAB recipes that I find useful or nice but don't use often enough to remember by heart.




Creating Videos

% Create video object
v = VideoWriter('filename.avi');

% Change video object options 
v.Option = OptionValue;

% Open video object 

% Generate and write frames to video object
for k = 1:20 
   Generate frame (plot, surf, etc...)
   frame = getframe;

% Close video object and create video

Useful Options,

  • FrameRate: number of frames per second (default is 30);
  • CompressionRate: rate between the pixels of original image to be compressed in the frame (default 10);
  • Duration;
  • FrameCount;





In April 7th, 2017, I gave a very introductory talk about the use of CUDA in MATLAB.
Its companion code may be found at my Git.