Main Content

Lines of Code for Stateflow Blocks Metric

Metric ID

Metric ID: mathworks.metrics.StateflowLOCCount


Metric Type: Size

Model Advisor Check ID: mathworks.metricchecks.StateflowLOCCount

Use this metric to calculate the number of effective lines of code in Stateflow®. Effective lines of MATLAB® code are lines of executable code. Empty lines, lines that contain only comments, and lines that contain only an end statement are not considered effective lines of code. This metric calculates the lines of code for the following Stateflow blocks in the model:

  • Chart, counting the code on Transitions and inside States

  • State Transition Table block

  • Truth Table block

This metric is available with Simulink® Check™. To collect data for this metric, use getMetrics with the metric identifier, mathworks.metrics.StateflowLOCCount.

The slmetric.metric.AggregationMode property setting is Sum.

Computation Details

The metric:

  • Runs on library models.

  • Analyzes content in masked subsystems.

  • If specified, analyzes the content of library-linked blocks or referenced models.


To collect results for this metric using the Model Advisor, run the check, Lines of code for Stateflow blocks metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the number of code lines for Stateflow blocks in the model. The check does not analyze referenced models or return aggregated results.


For this metric, instances of slmetric.metric.Result provide the following results:

  • Value: Number of Stateflow block code lines.

  • AggregatedValue: Number of Stateflow block code lines for a component and its subcomponents.

  • Measures: Vector with two entries: number of effective lines of code in MATLAB action language and number of effective lines of code in C action language.

See Also

Related Topics