Main Content

slreportgen.report.ScopeSnapshot Class

Namespace: slreportgen.report
Superclasses: slreportgen.report.Reporter

Create Simulink scope snapshot reporter

Since R2024b

Description

Create a Simulink® scope reporter. When added to a report, Simulink scope reporters create a snapshot of the specified scope block and adds the snapshot to the report as an image with an optional caption. Use the Source property to specify the desired scope.

Note

To use a ScopeSnapshot reporter in a report, you must create the report using the slreportgen.report.Report class.

The slreportgen.report.ScopeSnapshot class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

ssReporter = ScopeSnapshot creates an empty ScopeSnapshot object based on the default report template. Use the Source property to specify a Simulink scope block on which to report. Adding an ScopeSnapshot object with an empty Source property to a report produces an error.

ssReporter = ScopeSnapshot(source) sets the Source property to source. Adding this reporter to a slreportgen.report.Report object, without any further modification, adds the scope snapshot information based on default settings of the slreportgen.report.Report object. The snapshot displays in the generated report as an image with a caption. See slreportgen.report.Report.

example

ssReporter = ScopeSnapshot(PropertyName=Value) sets properties using one or more name-value arguments. You can specify multiple name-value arguments in any order.

Properties

expand all

Path or handle of the scope block for which to create a Simulink scope reporter, specified as a string scalar or a character vector.

Data Types: char | string

Snapshot reporter, specified as an mlreportgen.report.FormalImage object. Use the properties of the FormalImage object to specify the caption for the snapshot image or to customize the size of the image.

Note

The reporter initializes the Snapshot property. Do not clear or modify this property.

Attributes:

GetAccess
public
SetAccess
public

Snapshot image format, specified as one of these formats:

Import Image FormatFile ExtensionSupported in HTMLSupported in WordSupported in PDF

Supported in PDF/A (since R2025a)

Windows® metafile.emfNoYesNoNo
Graphics Interchange Format .gifYesYesYesYes
JPEG image.jpgYesYesYesNo
PDF.pdfNoNoYesNo
PDF/A.pdfNoNoYesNo
Portable Network Graphics (.png).pngYesYesYesYes
Scalable Vector Graphics.svgYesYesYesYes
TIFF image.tifNoYesYesYes

Note

Unlike the PDF report output format, the PDF/A format does not support including PDF or PDF/A images. Use one of the image formats listed in the table to include an image in a PDF/A report.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Scaling options for the snapshot image, specified as "auto", "custom", or "none". This property controls the size of the snapshot image in the image file. Supported scaling options are:

  • "auto" — For PDF or Word (DOCX) output, use this option to scale the snapshot image to fit the current page layout while maintaining its aspect ratio. First, the reporter scales the snapshot image to the page width. If the image height exceeds the page height, the reporter scales the image down again. This additional scaling ensures that the image fits the current page with an extra one inch spacing. Scaling does not apply to HTML output.

  • "custom" — Use this option to scale the snapshot image based on the values of the Height and Width properties.

  • "none" — Do not perform scaling

Note

The "auto" and "custom" options use the MATLAB® print command to resize the figure. If the figure is too large to fit in the specified space, the print command crops the snapshot image. To avoid cropping, set the Scaling property to "none" and use the reporter specified by the Snapshot property to size the image. Because the reporter reduces the size of the text with the rest of the image, fine details may not be legible unless you zoom the image. See Resize Figure Snapshot Image.

Note

A java.lang.OutOfMemoryError can occur when either of these combinations of property settings occur:

  • Scaling set to "zoom", and Zoom, MaxHeight, and MaxWidth properties set to large values

  • Scaling set to "custom", and Height and Width properties set to large values

To avoid this error, for zoom Scaling, use smaller Zoom, MaxHeight, and MaxWidth property values. For Scaling is set to "custom", use smaller Height and Width property values.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Height of the snapshot image, specified as a character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "2in" specifies two inches. The default snapshot is 6 inches. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Note

For a PDF image, the size limit is 10000px for width and height. For all other image types, the size limit is the screen size.

Example: "2in"

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Width of the snapshot image, specified as a character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "2in" specifies two inches. The default snapshot width is 6.5 inches. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Note

For a PDF image, the size limit is 10000px for width and height. For all other image types, the size limit is the screen size.

Example: "2in"

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Whether to preserve background color in the snapshot, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Set the background color of the snapshot to the same color as the background color of the snapshot source. The Theme property is ignored.

  • 0 (false) — Set the background color of the snapshot to the setting of the Theme property.

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Since R2025a

Graphics theme to use when printing the snapshot, specified as:

  • "light" — prints the figure with a white background and dark-colored graph lines and text.

  • "dark" — prints the figure with a dark-colored background and light-colored graph lines and text.

If you manually set any graphics colors, the snapshot preserves those colors, with the exception of the figure and axes background colors, regardless of theme setting. When PreserveBackgroundColor is true, this property is ignored.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Whether to scale the Simulink scope time axis to include entire log, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — The reporter scales the time axis and snapshot of the scope window includes the entire log.

  • 0 (false) — The reporter does not scale the time axis and the snapshot might not include the entire log.

Data Types: logical

Whether to force open closed scopes to snapshot, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Take a snapshot of all scopes in the context. This option forces closed scopes to open when the report generates and closes them afterwards.

  • 0 (false) — Only include the snapshot of the opened scopes.

Data Types: logical

Source of the template for this reporter, specified in one of these ways:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template this reporter uses or whose template library contains the template for this reporter

  • Document Object Model (DOM) document or document part whose template this reporter uses or whose template library contains the template for this reporter

The specified template must be the same type as the report to which you append this reporter. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true
Dependent
true

Name of the template for this reporter, specified as a character vector or string scalar. The template for this reporter must be in the template library of the template specified by the TemplateSrc property of this reporter.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar value converts to a LinkTarget object. The link target immediately precedes the content of this reporter in the output report.

Attributes:

GetAccess
public
SetAccess
public

Methods

expand all

Examples

collapse all

Create a report and add scope snapshots with both default and custom properties.

Add Scope Snapshot with Default Properties

import mlreportgen.report.*
import slreportgen.report.*

Add a scope snapshot using the default reporter properties to a report.

rpt = slreportgen.report.Report("MyScopeSnapshot","pdf");

Load and simulate the model.

model_name = "vdp";
load_system(model_name);
sim(model_name);

Create a chapter and title.

chapter = mlreportgen.report.Chapter(Title="Scope Block in Van der Pol Equation Model");

Create a ScopeSnapshot reporter using the scope path

reporter = slreportgen.report.ScopeSnapshot("vdp/Scope");

Add reporter to the chapter and chapter to the report

append(chapter,reporter);
append(rpt,chapter);

Add Scope Snapshot with Custom Properties

Add a scope snapshot with the original scope background color and a custom caption to a report.

Create a second chapter and title.

chapter = mlreportgen.report.Chapter(Title="Customized Version of Scope Snapshot");

Create a ScopeSnapshot reporter using the scope path and set its properties

reporter = slreportgen.report.ScopeSnapshot("vdp/Scope");
reporter.Snapshot.Caption = "Scope Snapshot with Custom Caption";
reporter.PreserveBackgroundColor = true;

Add reporter to the chapter and chapter to the report

append(chapter,reporter);
append(rpt,chapter);

Close and view the report.

close(rpt);
rptview(rpt);

Limitations

  • If you run your simulation with the parsim function, this class is not supported.

Tips

If the snapshot that the ScopeSnapshot object adds to your report is missing or empty, check the order in which you add reporters to your report. slreportgen.report.ScopeSnapshot objects require the model to be uncompiled in order to capture the window of the Scope block. Some reporters, such as slreportgen.report.Diagram, compile the model when you append them to the report. If you append one of these reporters before the ScopeSnapshot reporter, the ScopeSnapshot reporter cannot capture the scope window because the model is no longer uncompiled.

These reporters require a compile the model when you add them to the report:

Additionally, slreportgen.report.Diagram reporters require a compiled model when you enable execution-order, sorted-order, or timing overlays.

To prevent these issues:

  • If possible, append the ScopeSnapshot reporter to your report before any reporter that compiles the model:

    append(chapter, slreportgen.report.ScopeSnapshot(model + "/Scope"));
    append(chapter, slreportgen.report.Diagram(model));

  • If the reporting sequence requires ScopeSnapshot to occur after a reporter that compiles the model:

    1. Uncompile the model.

      slreportgen.utils.uncompileMode(model);
    2. Simulate the model.

      sim(model);
    3. Retrieve the DOM object that the ScopeSnapshot reporter uses and append it to the chapter. Appending the DOM object to the chapter forces the reporter to take the snapshot immediately, while the model is still uncompiled.

      reporter = slreportgen.report.ScopeSnapshot(model + "/Scope");
      reporterObj = getImpl(reporter,rpt);
      append(chapter,reporterObj);
    4. Recompile the model.

      slreportgen.utils.compileMode(model);

Version History

Introduced in R2024b

expand all