Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

snapnow - Force snapshot of image for inclusion in published document

GUI Alternative

As an alternative to snapnow, open an M-File and select Cell > Insert Text Markup > Force Snapshot to insert the snapnow command into the M-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 an M-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.

Example

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 an M-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

Forcing a Snapshot of Output in M-Files for Publishing

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS