Main Content

slreportgen.finder.ModelVariableResult Class

Namespace: slreportgen.finder
Superclasses: mlreportgen.finder.Result

Model variable search result object

Since R2019b

Description

Model variable search result object for a variable used in a Simulink® model or subsystem.

The slreportgen.finder.ModelVariableResult class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

You do not create an slreportgen.finder.ModelVariableResult object explicitly. The slreportgen.finder.ModelVariableFinder find or next methods create an slreportgen.finder.ModelVariableResult object for each variable that is found.

Properties

expand all

Public Properties

Additional user-defined information to add to the result, specified as any value.

Attributes:

NonCopyable
true

Data Types: any

Protected Properties

Simulink.VariableUsage object for the variable represented by this result.

Attributes:

SetAccess
protected

Name of the variable represented by this result, specified as a string scalar.

Attributes:

SetAccess
protected

Source of the variable definition, specified as a string scalar. This table shows example values.

ValueDescription
"base workspace"MATLAB® base workspace.
"MyModel"Model workspace for MyModel.
"MyModel/Mask1"Mask workspace for a masked block.
"my_data_dictionary.sldd"The data dictionary my_data_dictionary.sldd.

Attributes:

SetAccess
protected

Type of the workspace that defines the variable, specified as one of these string scalars:

  • "base workspace"

  • "model workspace"

  • "mask workspace"

  • "data dictionary"

This property is read-only.

Attributes:

SetAccess
protected

Blocks that use the variable, specified as a cell array of string scalars.

Attributes:

SetAccess
protected

Path of the Model block that set the variable value, specified as a string scalar.

Suppose that a referenced model uses a model argument to set a block parameter value. If a model has multiple instances of the referenced model, the model variable finder returns multiple instances of the variable that is associated with the model argument. The ModelBlockPath property uniquely identifies the instance of the variable by providing the path to the Model block that set its value. If a variable is not associated with a model argument in a referenced model, the ModelBlockPath is empty. For more information about referenced models and instance-specific parameters, see Parameterize Instances of a Reusable Referenced Model.

Attributes:

SetAccess
protected

Methods

expand all

Examples

collapse all

Customize the formatting of model variables in a report by iterating through the search results and setting properties of the model variable reporter for each result.

% Create a Report
rpt = slreportgen.report.Report("MyReport","pdf");

% Create a Chapter
chapter = mlreportgen.report.Chapter();
chapter.Title = "Model Variable Reporter Example";

% Load the model
model_name = "sf_car";
load_system(model_name);

% Find the variables in the model
finder = slreportgen.finder.ModelVariableFinder(model_name);

while hasNext(finder)
    result = next(finder);
    
    % Get the ModelVariable reporter for the result
    % Customize the formatting of numbers
    reporter = getReporter(result);
    reporter.NumericFormat = "%.4f";
    
    % Add the reporter to the chapter
    add(chapter,reporter);
end
% Add chapter to the report
add(rpt,chapter);

% Close the report and open the viewer
close(rpt);
rptview(rpt);

Version History

Introduced in R2019b