getNFlowBlockHandle
Return the handle of a block by path, or -1 if not found.
📝Syntax
h = getNFlowBlockHandle(path)
h = getNFlowBlockHandle(path, load)
📥Input Arguments
Parameter Description
path a block path ('model/BlockName'), or a cell array of block paths.
load optional logical; when true, an unloaded model is loaded first if it can be found.
📤Output Arguments
Parameter Description
h the numeric handle of the block, or -1 when it is not found. For a cell array of paths, a numeric array of the same shape.
📄Description

getNFlowBlockHandle returns the numeric handle of a block given its path, or -1 when the block does not exist (no error is raised).

The handle equals get_param(path, 'Handle') and can be passed to get_param and set_param in place of the path. A path that names only a model (with no block) resolves to -1.

With a cell array of paths, the result is a numeric array of handles of the same shape, each element being the handle or -1.

When load is true and the model is not loaded, it is loaded first if it can be found; otherwise the result is still -1.

💡Examples
new_system('demo');
add_block('nflow/math/gain', 'demo/Gain');
h = getNFlowBlockHandle('demo/Gain')
missing = getNFlowBlockHandle('demo/None')
get_param(h, 'BlockType')
bdclose('demo');
🔗See Also
getfullnameget_paramset_paramfind_system
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub