MATLAB: How to make a movie with one multidimensional matrix in MATLAB

imageMATLABmatrixmatrix manipulationvideovideo processing

Hello, I have a multidimensional matrix in MatLab -> T(41,41,501) and I would like to memorize all this matrix in a movie. What should I do?
I read that the function is VideoWriter but I couldn't make the video. I am attaching the matrix.
cheers.

Best Answer

VidObj = VideoWriter('movie.avi', 'Uncompressed AVI'); %set your file name and video compression
VidObj.FrameRate = 30; %set your frame rate
open(VidObj);
for f = 1:size(T, 3)
writeVideo(VidObj, T(:, :, f));
end
close(VidObj);