Main Content

validate

Determine whether block path represents valid block hierarchy

Description

example

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

  • All elements in the block path represent valid blocks

  • Each element except the last is a valid Model block and references the model of the following 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);

The function returns 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 the function does not return an error.

Input Arguments

collapse all

Fully specified block path, specified as a Simulink.BlockPath object. This block path uniquely identifies a block within a model hierarchy, even when the model hierarchy references the same model multiple times.

Introduced in R2010b