getSimulinkBlockHandle
R2026bGet block handle from block path
Description
returns the numeric handle of the block at the location specified by
handle = getSimulinkBlockHandle(path)path, provided it exists in a loaded model or library. The handle
applies only to the current MATLAB® session. If the block is not found, the function returns
-1. Library links are resolved where necessary.
Use the handle returned by getSimulinkBlockHandle to manipulate the
block in subsequent function calls. Doing so is more efficient than using the block path.
The number you see if you output the handle in the MATLAB Command Window is usually rounded. Do not use this value. Instead, assign the
handle to a variable.
Use the getSimulinkBlockHandle function to check whether a block
path is valid. This approach is more efficient than calling the
get_param inside a try statement.
To get the block path from the block handle, use the getfullname function.
attempts to load the model or library containing the block at the location specified by
handle = getSimulinkBlockHandle(path,true)path, and then checks if the block exists. No error is returned if
the model or library is not found. Any models or libraries loaded this way remain in memory
even if the function does not find a block with the specified path.
Examples
Input Arguments
Output Arguments
Version History
Introduced in R2015a