To answer the second question, see avifile() . However, I was better off deleting frames individually (problems with compression quality, if I remember correctly).
To save individual frames, you can use imwrite() or print() with the -dpng option or similar. From there, use sprintf() to generate the file name with your frame number in it, and you have most of what you need. However, you will need a video editing program (VideoMach, etc.) to turn these frames into a movie if you are not using Matlab avifile ().
source share