slreportgen.finder.ModelVariableResult class

Package: slreportgen.finder

Model variable search result object

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

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

Simulink.VariableUsage object for the variable represented by this result. This property is read-only.

Name of the variable represented by this result, specified as a character vector. This property is read-only.

Source of the variable definition, specified as a character vector. This property is read-only. 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.

Type of the workspace that defines the variable, specified as one of these character vectors:

  • 'base workspace'

  • 'model workspace'

  • 'mask workspace'

  • 'data dictionary'

This property is read-only.

Blocks that use the variable, specified as a cell array of character vectors. This property is read-only.

Path of the Model block that set the variable value, specified as a character vector. This property is read-only.

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

Additional information to save with this result. You can set it to any type of value.

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);

Introduced in R2019b