Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, I am just copying and pasting now, from <a href="http://www.mathworks.com/help/matlab/ref/videowriterclass.html" rel="nofollow noreferrer">here</a>. However I added <code>FrameRate</code> (per second) since you might want to use (or ask) it later.</p> <pre><code>writerObj = VideoWriter('Your_video.avi'); writerObj .FrameRate = 1; % 1 frames per second animation. open(writerObj); fig_h = figure; for i = 1: G contour(X1,X2,f); hold on plot(top(1:size(top,1)), 'rx'); frame = getframe(fig_h); % or frame = getframe; since getframe gets gcf. writeVideo(writerObj, frame); end close(writerObj); </code></pre> <p>Now you will have a <code>Your_video.avi</code> file in your working directory.</p> <hr> <p>If <a href="http://www.mathworks.com/help/matlab/ref/videowriterclass.html" rel="nofollow noreferrer"><code>VideoWriter</code></a> is not supported by your matlab, you could use use <a href="http://www.mathworks.com/help/matlab/ref/avifile.html" rel="nofollow noreferrer"><code>avifile</code></a> same as mentioned in <a href="https://stackoverflow.com/a/16831646/1698972">this</a> answer (or in mathwork documentaion example <a href="http://www.mathworks.com/help/matlab/ref/avifile.html" rel="nofollow noreferrer">here</a>) like this:</p> <pre><code>aviobj = avifile('Your_video.avi','compression','None', 'fps', 1); fig_h = figure; for i = 1:G contour(X1,X2,f); hold on plot(top(1:size(top,1)), 'rx'); frame = getframe(fig_h); % or frame = getframe; since getframe gets gcf. aviobj = addframe(aviobj, frame); end aviobj = close(aviobj); </code></pre> <hr> <p><strong>EDIT</strong></p> <p>A problem may occur as pointed out by <a href="https://stackoverflow.com/q/16885207/1698972">this question</a> also, which is the captured frame is a constant image. If you are running Matlab on windows, this problem may be caused by conjunction of windows in with certain graphics drivers, and may be solved as mentioned in <a href="https://stackoverflow.com/a/16885631/1698972">this answer</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload