This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Force snapshot of image for inclusion in published document




The snapnow command forces a snapshot of the image or plot that the code has most recently generated for presentation in a published document. The output appears in the published document at the end of the cell that contains the snapnow command. When used outside the context of publishing a file, snapnow has the same behavior as drawnow. That is, if you run a file that contains the snapnow command, the MATLAB® software interprets it as though it were a drawnow command.


This example demonstrates the difference between publishing code that contains the snapnow command and running that code. The first image shows the results of publishing the code and the second image shows the results of running the code.

Suppose you have a file that contains the following code:

%% Scale magic Data and
%% Display as Image:

for i=1:3

When you publish the code to HTML, the published document contains a title, a table of contents, the commented text, the code, and each of the three images produced by the for loop. (In the published document shown, the size of the images have been reduced.)

When you run the code, a single Figure window opens and MATLAB updates the image within this window as it evaluates each iteration of the for loop. Each successive image replaces the one that preceded it, so that the Figure window appears as follows when the code evaluation completes.

See Also

Introduced in R2008b

Was this topic helpful?