Main Content

validate

Determine whether block path represents valid block hierarchy

Description

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

example

Examples

collapse all

Open the project named ModelReferenceHierarchy.

openProject("ModelReferenceHierarchy");

The project opens a model hierarchy with sldemo_mdlref_depgraph as the top model.

Create a Simulink.BlockPath object that represents a block correctly.

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.

Suppose you create a Simulink.BlockPath object that represents a block incorrectly. For example, a model name or block name in the path has a typo. In this case, the function returns an error because the block path is invalid.

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.

Version History

Introduced in R2010b