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.

snapnow

Take snapshot of image for inclusion in published document

Syntax

snapnow

Description

example

snapnow, in a file being published, takes a snapshot of the most recently generated image or plot. The snapshot appears at the end of the code section that contains the snapnow command. For more information about publishing, see Publishing MATLAB Code.

Outside of the context of publishing a file, MATLAB® interprets a snapnow command as a drawnow command.

Examples

collapse all

Use snapnow to capture a snapshot of an image after each iteration of a loop.

Create a file loopIterations.m with this code that runs a for loop three times and produces graphics after every iteration.

%% Scale magic Data and Display as Image
for i=1:3
    imagesc(magic(i))
end

Save and then publish the file. MATLAB displays the published file with only a snapshot of the final image.

publish('loopIterations.m')
web('html/loopIterations.html')

Add a call to the snapnow function inside the for loop.

%% Scale magic Data and Display as Image
for i=1:3
    imagesc(magic(i))
    snapnow;
end

Save and then publish the file. MATLAB displays the published file with a snapshot for each loop iteration.

publish('loopIterations.m')
web('html/loopIterations.html')

Introduced in R2008b