validate

Determine whether the block path represents a valid block hierarchy

Description

example

validate(bp) determines whether the block path represents a valid block hierarchy. If the block path is invalid, you receive an error. The method checks that:

  • All elements in the block path represent valid blocks.

  • Each element except for the last element is a valid Model block and references the model of the next element.

Examples

collapse all

Create a Simulink.BlockPath object that incorrectly represents a referenced model within a model hierarchy.

load_system('sldemo_mdlref_depgraph')
bp = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...
'sldemo_mdlref_heater/F2C'});

Check whether the block path is valid.

validate(bp);

You receive an error because the block path is invalid; it does not specify the name of a block in the sldemo_mdlref_heater model.

Create a Simulink.BlockPath object that correctly represents the referenced model within a model hierarchy.

bp = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...
'sldemo_mdlref_heater/Fahrenheit to Celsius'});

Check whether the block path is valid.

validate(bp);

The block path is valid, so you do not receive an error.

Input Arguments

collapse all

A Simulink.BlockPath object, which represents a fully specified block path that uniquely identifies a block within a model hierarchy, even when the model hierarchy references the same model multiple times.

Introduced in R2010b