Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

snapnow

Force snapshot of image for inclusion in published document

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
    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. (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.

More About

See Also

Was this topic helpful?