getVariableValue

Class: slreportgen.finder.ModelVariableResult
Package: slreportgen.finder

Get value of variable from model variable search result

Syntax

value = getVariableValue(variableResult)

Description

value = getVariableValue(variableResult) returns the value of the variable represented by the model variable search result.

Input Arguments

expand all

Result of a search using the find or next method of an slreportgen.finder.ModelVariableFinder object.

Examples

expand all

If the getVariableValue method returns a Simulink.Bus object, use an slreportgen.report.BusObject object instead of an slreportgen.report.ModelVariable object to report on the bus object.

mdl = "sldemo_bus_arrays";
load_system(mdl);

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

% Find variables used by the model
f = slreportgen.finder.ModelVariableFinder(mdl);
results = find(f);

for r = results
    % If the result represents a Bus object, add a Bus object reporter to the
    % report
    if isa(getVariableValue(r), "Simulink.Bus")
        reporter = slreportgen.report.BusObject(r);
        % Add the reporter to a chapter in the report
        ch = mlreportgen.report.Chapter(reporter.Name);
        add(ch, reporter);
        add(rpt, ch);
    end
end

% Close and view the report
close(rpt);
rptview(rpt);

Introduced in R2019b