Skip to Main Content Skip to Search
Product Documentation

snapnow - Force snapshot of image for inclusion in published document

Alternatives

As an alternative to snapnow, open a MATLAB code file and select Cell > Insert Text Markup > Force Snapshot to insert the snapnow command into the file.

Syntax

snapnow

Description

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.

Examples

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
    i
    imagesc(magic(i))
    snapnow
end

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, along with a display of the value of i corresponding to each image. (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. (Concurrently, the Command Window displays the value of i.) Each successive image replaces the one that preceded it, so that the Figure window appears as follows when the code evaluation completes.

See Also

drawnow

How To

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS