Contenu principal

getVariableID

R2026b

Class: slreportgen.finder.ModelVariableResult
Namespace: slreportgen.finder

Get unique ID of model variable

Syntax

varID = getVariableID(variableResult)

Description

varID = getVariableID(variableResult) returns a string that uniquely identifies the variable represented by the model variable search result. This ID is the default value of the LinkTarget property of the slreportgen.report.ModelVariable reporter for the variable. Therefore, you can use the ID to generate a link to the reported content for the variable.

Input Arguments

expand all

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

Output Arguments

expand all

Unique ID for the model variable, returned as a string scalar.

Examples

expand all

Create a list of the model variables used by the sf_car model. In the PDF report, the variable names link to the reported content for the variables.

Load the model.

model_name = "sf_car";
openExample(model_name)

Create a report.

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

Create a chapter.

chapter = mlreportgen.report.Chapter();
chapter.Title = "Variables Used in the "+model_name+" model";

Find the variables in the model.

finder = slreportgen.finder.ModelVariableFinder(model_name);
results = find(finder);

Create a list of the variables with links to the reported variable content.

ul = mlreportgen.dom.OrderedList;
for r = results
    varname = r.Name;

Get the ID that is used for the link target for this variable.

    varid = getVariableID(r);
    link = mlreportgen.dom.InternalLink(varid,varname);
    li = mlreportgen.dom.ListItem();
    append(li,link);
    append(ul,li);
end
add(chapter,ul);

Add reporters for the variables to report.

for r = results

Get the ModelVariable reporter for the result.

    reporter = getReporter(r);

Customize the formatting of numbers.

    reporter.NumericFormat = "%.4f";

Add the reporter to the chapter.

    add(chapter,reporter);

end
add(rpt,chapter);

Close the report and open the viewer.

close(rpt);
rptview(rpt);

Version History

Introduced in R2019b