Main Content

slreportgen.finder.FunctionReferenceFinder Class

Namespace: slreportgen.finder
Superclasses: mlreportgen.finder.Finder

Find MATLAB function references in Simulink blocks

Since R2022a

Description

Use objects of the class slreportgen.finder.FunctionReferenceFinder to find function references that are specifically used for calculating parameters in Simulink® blocks.

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

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

funcRefFinder = slreportgen.finder.FunctionReferenceFinder(container) creates a FunctionReferenceFinder object and sets the Container property to container.

theReporter = slreportgen.finder.FunctionReferenceFinder(Name=Value) sets Properties using one or more name-value arguments.

example

Properties

expand all

Simulink model or block to search for function references, specified as one of these values:

ValueDescription
Model nameModel name, specified as a string scalar or character vector. For example, "sf_car"
Path to blockPath to block, specified as a string scalar or character vector. For example "sf_car/Engine"
Model handleModel handle, generated by the slreportgen.utils.getModelHandle function. For example slreportgen.utils.getModelHandle("sf_car")
Block handleBlock handle, generated by the getSimulinkBlockHandle function. For example, getSimulinkBlockHandle("sf_car/Engine")
slreportgen.finder.DiagramResult objectSearch result object that represents a Simulink model or subsystem
slreportgen.finder.BlockResult objectSearch result object that represents a Simulink block

Number of levels to search inside the container, specified as a nonnegative integer or inf to search in an unlimited depth.

Attributes:

GetAccess
public
SetAccess
public

Function type to search for, specified as one of these values:

ValueDescription
"all"Search for all function references
"built-in"Search for built-in function references
"user-defined"Search for user-defined function references

Attributes:

GetAccess
public
SetAccess
public

Data Types: string | char

Whether to search in the models that are referenced by the model or block represented by the Container property, specified as a logical 1 (true) or 0 (false). When SearchReferencedModels is true:

  • The finder searches only referenced models within the search depth are searched.

  • The finder searches referenced models to the depth specified by SearchDepth, regardless of the depth of the block that contains the referenced model.

  • The finder searches models that are referenced by referenced models.

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Whether to search under masks, specified as a logical 1 (true) or 0 (false).

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Whether to follow links to library blocks, specified as a logical 1 (true) or 0 (false).

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Whether to search for functions referenced by inactive variants in variant subsystems and model variants, specified as a logical 0 (false) or 1 (true).

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Properties of functions to find, specified as a cell array of name-value pairs in the format {"Name","Value"}. The finder returns only functions that have the specified properties with the specified values. Supported properties include any property of the slreportgen.finder.FunctionReferenceResult class.

Data Types: cell

Methods

expand all

Examples

collapse all

This example shows how to find and report on MATLAB function references in Simulink blocks.

Import these namespaces so that you do not have to use long, fully qualified class names.

import slreportgen.report.*
import slreportgen.finder.*

Create an slreportgen.report.Report of type PDF.

theReport = Report("FunctionReferenceReport","pdf");

Open the model slrgex_fuelsys and then compile the model so that the finder searches the most updated version of the model.

modelName = "slrgex_fuelsys";
open_system(modelName);
slreportgen.utils.compileModel(modelName);

Create an slreportgen.finder.FunctionReferenceFinder object.

funcRefFinder = FunctionReferenceFinder(modelName);

Set the finder to search in referenced models.

funcRefFinder.SearchReferencedModels = true;

Use the methods hasNext and next iteratively to fetch the slreportgen.finder.FunctionReferenceResult objects one at a time.

while(hasNext(funcRefFinder))
  nextRes = next(funcRefFinder);

If the referenced function is a built-in function, append the result directly to the report.

  if(nextRes.FunctionType == "built-in")
    append(theReport,nextRes);

If the referenced function is a user-defined function, obtain a handle of the slreportgen.report.FunctionReference reporter of this result. Customize the reporter to exclude the references table by setting the ShowReferencesTable property of the reporter to false. Then append the reporter to the report.

  else
    reporter = getReporter(nextRes);
    reporter.ShowReferencesTable = false;
    append(theReport,reporter);
  end
end

Uncompile and close the model.

slreportgen.utils.uncompileModel(modelName)
close_system(modelName);

Close and view the report.

close(theReport);
rptview(theReport);

Version History

Introduced in R2022a