Main Content

socModelAnalyzer

Estimate number of operations in Simulink model

Since R2020a

Description

example

socModelAnalyzer(modelName) generates a report with the estimated number of operations in a Simulink® model specified by modelName.

The function generates the report as a Microsoft® Excel® spreadsheet and a MAT-file. The function also provides a link to view the report in a separate dialog box.

The report includes information for each mathematical or logical operator in the function, with individual lines for each operator and data type. For example, multiplication with data type double and multiplication with data type uint32 are listed separately. The report lists each instance of the operator as a separate line. The report includes these fields.

  • Path – The path to the operator within the structural hierarchy of the top function

  • Count – The number of times the operator is executed in the design

  • Operator – The operator used

  • DataType – The data type used for the output of the operator

  • Link – A link to the location of the operator in the function

For more information, see Using the Algorithm Analyzer Report.

example

socModelAnalyzer(modelName,Name=Value) specifies options using one or more name-value pair arguments. For example, IncludeOperator='+' specifies that the generated report only includes '+' operator counts.

example

report = socModelAnalyzer(___) returns a structure of tables that contain report information. Specify any of the input argument combinations from previous syntaxes.

Examples

collapse all

Calculate the number of dynamic operations and static operators in the model testmdl.slx.

Generate Dynamic Report

Count operations in testmdl, and generate a report in a folder named report.

socModelAnalyzer('testmdl.slx',Folder='report');

View Dynamic Report

After generating the dynamic report, the socModelAnalyzer function provides a link to the generated report. View the dynamic analysis report by clicking the Open report viewer link. The report opens in a separate window.

The result shows that the ADD operator is used 11 times with data type matrix 10 uint32, and 22 times with data type uint32. The GT (greater than) operator was used 22 times total with data type logical: 11 times from SubAdd model, and 11 times from SubMult model. The MUL operator is used 11 times with data type uint32, and 11 times with matrix 10 uint32.

Generate Static Report

Statically calculate the number of operators in the model by using the AnalysisMethod name-value argument.

socModelAnalyzer('testmdl.slx',AnalysisMethod='static',Folder='report');

View Static Report

View the static analysis report, by clicking the Open report viewer link. The static report opens in a separate window.

Input Arguments

collapse all

Simulink model to analyze, specified as a character vector or string scalar.

Example: 'soc_analyze_FFT_top.slx'

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: socModelAnalyzer('mySocModel.slx',Folder='report_sym')

Option for static of dynamic analysis, specified as 'static' or 'dynamic'. This value specifies the method that the function uses to analyze the Simulink model.

  • 'dynamic' – Dynamic analysis provides the number of operations the model executes during a given simulation time.

  • 'static' – Static analysis provides the number of operators in an algorithm.

Example: AnalysisMethod='static'

Folder location of generated report, specified as a character vector or string scalar indicating the folder path. Specify the path to the location for the generated output reports as a full path or relative path.

Example: Folder='C:/Work/mydir'

Operators to include in the generated report , specified as a character vector or string scalar to specify one operator. Use cell array of character vectors or string scalars to specify multiple operators. When you do not specify this name-value pair argument, the socModelAnalyzer function includes all operators, except for the operators specified by the ExcludeOperator name-value pair argument.

Example: IncludeOperator='+'

Example: IncludeOperator={'+','IF','MUL'}

Operators to exclude from the generated report, specified as a character vector or string scalar to specify one operator. Use cell array of character vectors or string scalars to specify multiple operators. When you do not specify this name-value pair argument, the socModelAnalyzer function includes all operators in the report.

Example: ExcludeOperator='-'

Example: ExcludeOperator={'-','CALL'}

Models or blocks to include in generated report, specified as a character vector or string scalar to specify one block or model. Use cell array of character vectors or string scalars to specify multiple blocks or models. If you do not specify this name-value pair argument, the socModelAnalyzer function includes all models and blocks in the report, except for the blocks specified by the 'ExcludeBlockPath' name-value pair argument. Use the 'IncludeBlockPath' name-value pair when you have a test bench model, and you only want to analyze one of the models it includes.

Example: IncludeBlockPath='myModel.slx'

Example: IncludeBlockPath={'myModel.slx','myIfft'}

Models or blocks to include in generated report, specified as a character vector or string scalar to specify one block or model. Use cell array of character vectors or string scalars to specify multiple blocks or models. If you do not specify this name-value pair argument, the socModelAnalyzer function includes all models and blocks in the report.

Example: ExcludeBlockPath='myOtherModel.slx'

Example: ExcludeBlockPath={'myOtherModel.slx','myIfft'}

Display verbose messages, specified as on, off, or quiet. When you set Verbose to:

  • on — the function displays detailed messages during the different stages of execution.

  • off — the function displays messages during the first and last stages of execution.

  • quiet — the function does not display messages about execution. Select this option if you want to silence all messages.

Example: Verbose='on'

Output Arguments

collapse all

Model operator count, returned as a structure of five tables:

  • OperatorDetailedReport – A fully detailed report per operator

  • OperatorAggregatedReport – An aggregated operator view, with one line for each type of operator

  • OperatorHierarchicalReport – A hierarchical operator view

  • PathAggregatedReport – An aggregated model view

  • PathHierarchicalReport – A Hierarchical model view

Each table contains raw data from which the function generates an HTML view, and a link to view the data in a report window. The generated Excel file has five sheets, containing the information from the five tables. For more information about the generated report, see Using the Algorithm Analyzer Report.

Limitations

  • This function does not support AUTOSAR Blockset blocks or models.

  • This function does not support Simulink send and receive messages.

Tips

Identical atomic subsystems are optimized by Simulink into a single function by default, which can lead to incorrect results. To avoid this process, perform one of these actions:

  • Clear the Treat as atomic unit parameter in the subsystem block mask.

  • Set the Function packaging parameter to Nonreusable function in the subsystem block mask.

  • Modify one of the two subsystems so that it is not identical to the other one.

Version History

Introduced in R2020a

expand all