Get Handles and Paths
To take action programmatically in Simulink®, you must specify the target of the action. The target object can be a model, a component— such as a subsystem or library— or a model element, such as a block or signal line. To specify the target object, use a handle or path.
This topic provides a conceptual overview of Simulink handles and paths, explains how to specify a target object, and shows you how to get the handles and paths that workflow requires. You can specify target objects whose names and locations you know, or you can programmatically search for target objects that fit certain criteria. For information about how to search for target objects, see Search Programmatically.
Programmatically Specify Target of Action
Typically, to take an action programmatically, you run a function in a script or in the MATLAB® Command Line. The software uses the information you provide in the function inputs to determine the target object and how to take the action.
For example, suppose you want to change the value of a Constant block. To
make the change, you can use the set_param
function. In the function
inputs, you must tell the software which block you want to edit, which block parameter you
want to edit, and what you want the new value to be. This code changes the value of a
Constant block named myBlock
in a subsystem named
mySubsystem
in a model named myModel
to
5
.
set_param("myModel/mySubsystem/myBlock",Value="5")
myModel/mySubsystem/myBlock
is a block path. A
path is a string or character vector that specifies the location of
a target object relative to the top level of the model. Generally, the path starts with the
model name and ends with the name of the target object. Port paths can also end with a port
number. See Specify Port for details. The names
in the path must match the names in the model hierarchy exactly, including white spaces. For
information about how to specify paths that contain multiline names or special characters,
see Specify Paths That Contain Multiline Names and Special Characters.
Instead of a path, you can also provide a handle. A handle is a MATLAB data type that stores an association to a target object. When you output the value of a handle, the MATLAB Command Window displays a number. Do not try to use the displayed number, because the command window does not display all the digits and handles do not persist across Simulink sessions. Instead, store the handle value in a variable, and then use the variable to specify the target object.
To set the value of the Constant block from the previous example using a
handle, get the block handle. If you have the block path, you can get the handle using the
getSimulinkBlockHandle
function.
h = getSimulinkBlockHandle("myModel/mySubsystem/myBlock")
ans = 313.0001
Then, in the set_param
function, specify the handle instead of the
path as the first input argument.
set_param(h,Value="5")
For some actions, using a handle or path to specify the target object is not supported.
Instead, you must provide the name of the programmatic object that specifies the attributes
of the target object in the model. For example, for an annotation, specify the name of the
Simulink.Annotation
object.
Decide Whether to Use Handle or Path
To take action using a function, in the function documentation, check whether the function accepts only handles, only paths, or both as input arguments. If the function accepts both handles and paths, consider using handles.
The handle of a target object persists even when the path of the target object changes. If your code changes the path of a target object, or if you plan to do work on a model that changes the path of a target object, use handles.
Simulink processes handles faster than paths. To reduce run time, use handles.
For most target objects, if you have a path, you can get the corresponding handle and vice versa. To learn how, see Convert Between Handles and Paths.
Specify Model, Library, or Subsystem
Generally, to specify a model, library, or subsystem, you use a handle or filename. However, if the model, library, or subsystem is referenced by another model, library, or subsystem, depending on the action you want take, you might need to specify the reference block instead. For example, to take action on a subsystem that is referenced by a model, you might need to specify the subsystem, or you might need to specify the Subsystem Reference block that references the subsystem. First, determine which target object to specify. Then, determine how to specify that target object.
Determine Whether to Specify Reference Block
To take programmatic action using a function, read the function documentation and determine what type of target object you can specify in the input arguments. If the function can only act on models, libraries, subsystems, or a subset of these, or if the function can only act on blocks, you know what to specify. Otherwise, use the interactive approach to the workflow as a guide.
When you edit a model, library, or subsystem interactively, you can take some actions on the component by opening the component and interacting with the contents. To make the same edits programmatically, specify the component. You can take other actions by interacting with blocks that reference the component. To take the same actions programmatically, specify the block.
For example, suppose you have a subsystem that is saved to a subsystem file named
mySubsystem
. You also have a model named myModel
containing a Subsystem Reference block named
mySubsystemRefBlock
that references the subsystem. To change the
canvas color of the subsystem, use the set_param
function. In the
function input arguments, specify the subsystem.
set_param("mySubsystem","ScreenColor","green")
To see the change in the model, you must update the model diagram. To programmatically
update the diagram, use the set_param
function. In the function input
arguments, specify the model.
set_param("myModel","SimulationCommand","Update")
To treat the subsystem as atomic, use the set_param
function. In
the function input arguments, specify the Subsystem Reference block.
set_param("myModel/mySubsystemRefBlock",TreatAsAtomicUnit="on")
To get a list of the parameters that you can get and set programmatically when you
specify a model, first, load the model by entering this command in the MATLAB Command Window. myModel
is the model filename.
load_system("myModel")
Then, enter this command.
get_param("myModel","ObjectParameters")
To get a list of the parameters that you can get and set programmatically when you
specify a block, load the model containing the block. Then, enter these commands.
path
is the block path.
param = get_param(path,"ObjectParameters");
param = fieldnames(param)
The list of parameters output by these commands does not include the mask parameters you can get and set on a masked block when you specify the block. To get a list of the mask parameters, enter these additional commands.
paramMaskStruct = get_param(path,"DialogParameters");
paramMask = fieldnames(paramMaskStruct)
If you determine that you need to specify a model, library, or subsystem, see the next section. If you determine that you need to specify a reference block, see Specify Block.
Specify Model, Library, Subsystem, or Current System
To programmatically specify a model, library, or subsystem, use a handle or filename.
For example, to set the solver of a model named myModel
with the handle
h
to ode45
, use one of the commands in the
Example column of the table.
Option | Example |
---|---|
Handle |
set_param(h,SolverName="ode45") |
Filename |
set_param("myModel",SolverName="ode45") |
To specify the current system, use the handle or filename of the current system. For
the definition of the current system, see gcs
. To get the model that contains the current system, use the bdroot
function.
Action | Function | Example |
---|---|---|
Get filename of current system. | gcs |
path = gcs |
Get handle of current system. |
h = get_param(gcs,"Handle") |
If a file is not in the current folder or on the MATLAB search path, using the filename to specify the model, library, or subsystem the file contains is not supported. In this case, take one of these actions.
Specify the model, library, or subsystem using the file path ending with the filename, for example
C:\Users\user1\Documents\myFolder\myModel
.Change directories to the folder containing the file using the
cd
function.Add the file to the MATLAB search path using the
addpath
function.Move the file into the current folder.
Get Model, Subsystem, or Library Handle
You can programmatically get the handle of a loaded model, library, or subsystem, you can get the handle of a model, library, or subsystem while taking certain actions, and you can get the handle of the harness model for a protected model.
To get the handle of a loaded model, library, or subsystem, use this command.
h = get_param("myModel","Handle")
The table shows how you can get the handle of a model, library, or subsystem while taking an action. Use the function documentation to select a syntax that outputs the model, library, or subsystem handle.
Action | Function | Example |
---|---|---|
Create model, library, or subsystem. | new_system |
h = new_system("myModel") |
Create model or project from template. | Simulink.createFromTemplate |
h = Simulink.createFromTemplate("myTemplate") |
Load model, library, or subsystem. | load_system |
h = load_system("myModel") |
Find model, subsystem, or library. | find_system |
h = find_system("myModel",FindAll="on") |
Find loaded models and libraries. | Simulink.allBlockDiagrams |
h = Simulink.allBlockDiagrams("model") |
To get the handles of multiple models, libraries, or subsystems at once using the
load_system
, get_param
,
new_system
, or find_system
function, specify
the model filenames as one of these.
How to Specify Multiple Models, Libraries, or Subsystems | Example |
---|---|
Filenames specified as string array |
models = ["myModel1";"myModel2";"myModel3"]; h = get_param(models,"Handle") |
Filenames specified as cell array of character vectors |
models = {'myModel1';'myModel2';'myModel3'}; h = get_param(models,"Handle") |
To get the handle of the harness model for a protected model, use the Simulink.ModelReference.protect
(Embedded Coder) function.
h = Simulink.ModelReference.protect("myModel",Harness=true)
Specify Block
To programmatically specify a block, use the block handle or path. For example, to get
the gain value of a Gain block named myBlock
in a model
named myModel
with the handle h
, use one of the
commands in the Example column of the table.
Option | Example |
---|---|
Handle |
gain = get_param(h,"Gain")
|
Path |
gain = get_param("myModel/myBlock","Gain") |
To specify the current block, use the handle, path, or Simulink.BlockPath
object of the current block. For the definition of the
current block, see gcb
.
Action | Function | Example |
---|---|---|
Get path. | gcb |
path = gcb |
Get Simulink.BlockPath object. | gcbp |
pathObject = gcbp |
Get handle. | gcbh |
h = gcbh |
Get Block Path
The block path specifies the location of the block relative to the top level of the
model. Generally, the path starts with the model name and ends with the block name, for
example, myModel/mySubsystem/myBlock
.
If the block is in a referenced model, the block path is the path from the top level
of the referenced model to the block. To take inventory of blocks in referenced models,
get the Simulink.BlockPath
objects corresponding to
the blocks . A Simulink.BlockPath
object uniquely identifies a block
within a model hierarchy, even when the model hierarchy references the same model multiple
times. If you do not have a Simulink license, use a Simulink.SimulationData.BlockPath
object
instead.
To get the path of a Library Browser block:
Open the quick insert menu by double-clicking the model canvas.
Enter the block name.
Use your arrow keys to select the block in the quick insert menu search results.
On the details pane, click the name of the library that contains the block. The library opens. The block is highlighted in yellow.
Select the block.
Get the path of the current block using this command.
gcb
Tip
To get the handle of the library block instead, use
gcbh
instead.
Get Block Handle
You can programmatically get a block handle from a block path, you can get a block handle while taking certain actions, and you can get the handle of the block that a specific port is on or to which a specific signal line connects.
To get a block handle from a block path and load the model with one command, use the
getSimulinkBlockHandle
function with this
syntax. path
is the block path, specified as a string or character
vector.
h = getSimulinkBlockHandle(path,true)
To get the handle of a block in a loaded model, use this syntax.
h = getSimulinkBlockHandle(path)
To get the handles of multiple blocks at once using the
getSimulinkBlockHandle
function, specify the block paths as a cell
array of character vectors.
paths = {'myModel/myBlock1';'myModel/myBlock2';'myModel/myBlock3'}; h = getSimulinkBlockHandle(paths)
The table shows how you can get the handle of a block while taking an action. Use the function documentation to select a syntax that outputs the block handle.
Action | Function | Example |
---|---|---|
Add blocks. | add_block |
h = add_block("simulink/Sinks/Scope","myModel/myBlock") |
Find blocks. | find_system |
h = find_system("myModel",FindAll="on",Type="block") |
Simulink.findBlocks |
hModel = get_param("myModel","Handle"); h = Simulink.findBlocks(hModel) | |
Simulink.findBlocksOfType |
h = Simulink.findBlocksOfType("myModel","Integrator") | |
Replace blocks. | replace_block |
path = replace_block("myModel","Scope","simulink/Sinks/To Workspace") h = getSimulinkBlockHandle(path) |
Connect blocks. Connecting blocks in different levels of the model hierarchy can create new blocks, such as Inport blocks in a subsystem. | See Get Types, Handles, and Paths of Model Elements Created by Simulink.connectBlocks Function for details. |
connection = simulink.connectBlocks(hSrcPort,hDstPort);
transits = connection.getTransits;
hFunc1 = @(t) transits(t).getType=="block";
hFunc2 = @(t) transits(t).getHandle;
i = 1:numel(transits);
isTypeBlock = arrayfun(hFunc1,i);
h = arrayfun(hFunc2,i);
h = h(isTypeBlock==1) |
To get the handle and path of the block that a port is on, use these commands.
hPort
is the port handle. To get the handles and paths of the blocks
for multiple ports at once, specify hPort
as a vector of port
handles.
path = get_param(hPort,"Parent")
h = getSimulinkBlockHandle(path)
To get the handles of the source and destination blocks of a signal line, use these
commands. hLine
is the line handle. If hLine
represents the trunk of a branched signal line, the output is the destination blocks of
all branches. If hLine
represents one branch of a branched signal line,
the output is the destination block of that branch. To get the handles of the source and
destination blocks of multiple signal lines at once, specify hLine
as a
vector of line handles.
hSrc = get_param(hLine,"SrcBlockHandle") hDst = get_param(hLine,"DstBlockHandle")
Specify Port
To programmatically specify ports, use the port handle or path. For example, suppose you
have a model named myModel
. To connect the single output port of an
unconnected block named myBlock1
to the single input port of an
unconnected block named myBlock2
, use one of the commands in the
Example column of the table. hSrcPort
is the
output port handle. hDstPort
is the input port handle.
Option | Example |
---|---|
Handle |
Simulink.connectBlocks(hSrcPort,hDstPort) |
Path |
Simulink.connectBlocks("myModel/myBlock1/1","myModel/myBlock2/1") |
Get Port Path
The port path specifies the location of the port relative to the top level of the
model. Generally, the path starts with the model name and ends with the port number, for
example, myModel/myBlock/1
.
To get the port number interactively, in the model, pause your pointer on the port.
The port number appears in the canvas next to the port. To get the port number of a
component block, such as a Subsystem or Model block, enter
the component and pause your pointer on the block corresponding to the port, for example
an In1 block. If you have a port handle, h
, you can get
the port number programmatically using this command.
portNum = get_param(h,"PortNumber")
There are some exceptions to the described path format.
One exception pertains to conditionally executed subsystems. The path that specifies
the control input port on a conditionally executed subsystem starts with the model name
and ends with the port name, for example, myModel/Triggered
Subsystem/Trigger
. The table lists the names of the control input ports for
different types of conditionally executed subsystems.
Conditionally Executed Subsystem | Port Name |
---|---|
Triggered | Trigger |
Enabled | Enable |
Enabled and Triggered |
|
Resettable | Reset |
If Action | Ifaction |
Switch Case Action | Ifaction |
Function-Call | Trigger |
Message Polling | Trigger |
Message Triggered | Trigger |
Another exception pertains to buses. Suppose you want to query or edit the attribute
value of a bus or bus element at a bus element port. For example, suppose you want to get
or set the minimum value of a bus element at the point where the bus enters a subsystem.
Use the get_param
or set_param
function. In the input arguments, specify the bus or bus element at the bus element port
using a path.
If the In Bus Element or Out Bus Element block corresponding to the bus element port is at the top level of a model, start the path with the model filename. If the block is at the top level of a subsystem, start with the block path. To query or edit the attribute value of a bus, append a forward slash and the port name to the end of the path. To query or edit the attribute value of a bus element, append a forward slash and the bus element path. For a bus element port, the bus element path provides the hierarchy from the top-level bus to the target element, separating each name in the hierarchy with a dot. Specify the top-level bus using the port name.
For example, suppose you have a model named myModel
. The model
contains a Subsystem block named mySubsystem
. The
Subsystem block has a port named InBus
. Inside the
subsystem is an In Bus Element block named myBlock
. The
In Bus Element block selects the bus element named
Step
from the bus connected to the port named
InBus
. This path specifies the bus element named
Step
at the Subsystem block port named
InBus
.
path = "myModel/mySubsystem/myBlock/InBus.Step"
To programmatically get the name of the port on a In Bus Element or
Out Bus Element block, use this command. block
is the
block handle or path.
portName = string(get_param(block,"PortName"));
To get the name of the bus element that an In Bus Element or Out Bus Element block selects, use this command.
elemName = string(get_param(block,"Element"));
To get the name of the port or selected bus element of multiple In Bus
Element or Out Bus Element blocks at once, specify
b
as a vector of handles or as a set of paths in a string array or
cell array of character vectors.
Get Port Handle
You can programmatically get the handles of the ports on a specific block or the ports to which a specific signal line connects.
To get all port handles of a block, use this command. b
is the
block handle or path.
h = get_param(block,"PortHandles")
To get the handles of the input and output ports of the block, enter these additional commands.
hIn = h.Inport hOut = h.Outport
If the block represents a conditionally executed subsystem, to get the handles of the
control input port, enter an additional command of this form. The command uses dot
notation and the port name to extract the control input port handle from
h
. In this case, the port name is Trigger
.
hCtrlPort = h.Trigger
To get all port handles of multiple blocks at once, specify the blocks as one of these.
How to Specify Multiple Blocks | Example |
---|---|
Vector of handles |
blocks = [h1;h2;h3];
h = get_param(blocks,"PortHandles") |
Set of block paths specified as a string array |
blocks = ["myModel/myBlock1";"myModel/myBlock2";"myModel/myBlock3"]; h = get_param(blocks, "PortHandles") |
Set of block paths specified as a cell array of character vectors |
blocks = {'myModel/myBlock1';'myModel/myBlock2';'myModel/myBlock3'}; h = get_param(blocks, "PortHandles") |
The output is a cell array. Each cell contains a structure that stores the port
handles of one block. To get all the port handles of a specific block from
h
, use this command, where i
is the index of the
block in h
.
hBlockPorts = h{i}
To get the handles of all ports of a specific type stored in h
,
you can use the arrayfun
function. For example, to get the
handles of all output ports stored in h
, use these commands. The first
command specifies a function that takes the value t
as input. The
function gets all output ports stored in the structure with index t
.
The second command defines and populates the vector named i
, which
contains the indices of all the structures stored in h
. The last
command runs the function named hFunc
for each index in the vector
named i
.
hFunc = @(t) h{t}.Outport; i = 1:length(h); hOutports = arrayfun(hFunc,i)
To get the handles of the source and destination ports of a signal line, use these
commands. hLine
is the line handle. To get the port handles of multiple
signal lines at once, specify the signal lines as a vector of handles.
hSrc = get_param(hLine,"SrcPortHandle") hDst = get_param(hLine,"DstPortHandle")
Specify Signal and Signal Line
To programmatically specify instance-specific properties of a signal or a discrete
state, use the Simulink.Signal
object. For example, use the
Simulink.Signal
object to specify the units or the maximum or minimum
value of the signal.
To programmatically specify signal lines, use the line handles, or the handles or paths
of the source and destination ports of the signal line. For example, to delete a signal line
that connects the single output port of a block named myBlock1
to the
single input port of a block named myBlock2
in a model named
myModel
, use one of the commands in the Example
column of the table. hLine
is the handle of the signal line,
hSrcPort
is the handle of the outport of myBlock1
,
and hDstPort
is the handle of the input port of
myBlock2
.
Option | Example |
---|---|
Line handles |
delete(hLine) |
Port handles |
delete(hModel,hSrcPort,hDstPort) |
Port paths |
delete(hModel,"myModel/myBlock1/1","myModel/myBlock2/1") |
You can programmatically get the handle of a signal line while taking certain actions, you can get the handles of the signal lines connected to a specific block or port, you can get the handles of all lines with a signal line label you specify, and you can get the handle of the currently selected signal line.
The table shows how you can get the handle of a signal line while taking an action. Use the function documentation to select a syntax that outputs the line handle.
Action | Function | Example |
---|---|---|
Add signal line. | See Get Types, Handles, and Paths of Model Elements Created by Simulink.connectBlocks Function for details. |
connection = simulink.connectBlocks(hSrcPort,hDstPort);
transits = connection.getTransits;
hFunc1 = @(t) transits(t).getType=="line";
hFunc2 = @(t) transits(t).getHandle;
i = 1:numel(transits);
isTypeLine = arrayfun(hFunc1,i);
h = arrayfun(hFunc2,i);
h = h(isTypeLine==1) |
add_line |
h = add_line(hModel,hSrcPort,hDstPort) | |
Find signal line. | find_system |
h = find_system(hModel,FindAll="on",Type="line") |
To get the handles of signal lines connected to a block, use this command.
block
is the block handle or path.
h = get_param(block,"LineHandles")
To get the line handles of multiple blocks at once, specify the blocks as one of these.
How to Specify Multiple Blocks | Example |
---|---|
Vector of handles |
blocks = [h1;h2;h3];
h = get_param(blocks,"LineHandles") |
Set of block paths specified as a string array |
blocks = ["myModel/myBlock1";"myModel/myBlock2";"myModel/myBlock3"]; h = get_param(blocks,"LineHandles") |
Set of block paths specified as a cell array of character vectors |
blocks = {'myModel/myBlock1';'myModel/myBlock2';'myModel/myBlock3'}; h = get_param(blocks,"LineHandles") |
To get the handles of the signal line connected to a port, use this command.
hPort
is the port handle. To get the line handles of multiple ports at
once, specify the ports as a vector of handles.
h = get_param(hPort,"Line")
To get all signal lines in the model with a signal line label you specify, use the
find_system
function. For example, to get all signal lines with the
signal line label myLabel
, use this command.
h = find_system(gcs,Findall="On",Type="Line",Name="myLabel")
To get the handle of the currently selected line, use this command.
h = find_system(gcs,SearchDepth=1,FindAll="on",... Type="line",Selected="on")
Specify Annotation
To programmatically specify an annotation, use a handle or the name of the Simulink.Annotation
object.
To get and set the values of annotation parameters, you can use the get_param
and set_param
functions and specify the
annotation as a handle. Alternatively, you can specify the annotation using name of the
Simulink.Annotation
object and use dot notation. For example, to set the
text of the Simulink.Annotation
object named a
with the
handle h
to New text
, use one of the commands in the
Example column of the table.
Option | Example |
---|---|
Handle |
set_param(h,Text="New text") |
Simulink.Annotation object |
a.Text = "New text" |
You can programmatically get the Simulink.Annotation
object of a new
annotation when you create the annotation , and you can get the
Simulink.Annotation
object and handle of existing annotations, the
currently selected annotation, and the annotation from which a callback function was
invoked.
To get the Simulink.Annotation
object when you programmatically create
an annotation, use the Simulink.Annotation
function. For example, to
create an annotation with the text My annotation text
in a model named
myModel
and get the Simulink.Annotation
object, use
this command.
obj = Simulink.Annotation("myModel","My annotation text")
To get the handle of an annotation from the Simulink.Annotation
object,
run this command. a
is the Simulink.Annotation
object.
h = a.Handle
To get the handle of an existing annotation when you do not have the
Simulink.Annotation
object, programmatically search for the annotation
using the find_system
function. By default, the
find_system
function only searches for models and blocks. To include
annotations in the search, set the value of the FindAll
search criteria
option to "on"
. For example, to find the annotations containing the text
clutch
in a model named myModel
, use these
commands.
find_system("myModel",Findall="on", Regexp="on",... Type="Annotation", Name="clutch")
To get the Simulink.Annotation
object from an annotation handle, use
the get_param
function.
obj = get_param(h,"Object")
To get the Simulink.Annotation
object of the currently selected
annotation, use the getCurrentAnnotation
function. To get the Simulink.Annotation
object of the annotation from which a callback function was invoked, use the getCallbackAnnotation
function.
To create a new area annotation, specify the built-in area annotation as a string or
character vector containing the text built-in/Area
.
Convert Between Handles and Paths
When taking action programmatically, you might need to convert between handles and paths. For example, if you have a block path, but the input argument of the function you want to run must be a handle, you must get the block handle corresponding to the block path you have. The table shows how to make these conversions.
Have This | Convert To This | Syntax |
---|---|---|
Model handle | Model filename | name = get_param(h,"Name") To get the handles of multiple models at once, specify the models as an array of handles. |
Model filename | Model handle | If the model is not loaded, use this command. h = load_system("myModel") If the model is loaded, use this command. h = get_param("myModel","Handle") To get the handles of multiple models at once, specify the model filenames as a string array or a cell array of character vectors. |
Block handle | Block path | path = getfullname(h) To get the paths of multiple blocks at once, specify the blocks as a vector of handles. |
Block path | Block handle | h = getSimulinkBlockHandle(path) To get the handles of multiple blocks at once, specify the block path as a cell array of character vectors. |
Port handle | Port path that ends with port number | path = get_param(hPort,"Parent")+"/"+get_param(hPort,"PortNumber") To get the paths of multiple ports at once, specify the ports as a vector of handles. |
Port path that ends with port number | Port handle | splitPath = string(split(path,"/")); portNum = str2num(splitPath(end)); blockPath = erase(path,"/"+portNum); h = find_system(blockPath,Findall="on",Type="Port",PortNumber=portNum) If
multiple ports in your model have the same port path, get_param(h(i),"PortType") |
Simulink.Annotation object | Annotation handle |
h = a.Handle |
Annotation handle | Simulink.Annotation object |
obj = get_param(h,"Object") |
Get Handle of Attached Block, Attached Ports, and Connected Signal Lines
If you have a block handle, using the get_param
function, you can get the handles of the block ports and the handles
of the signal lines connected to the block, and vice versa. The table shows how to use the
handle of one of these target objects to get the handle of another. In the syntaxes listed
in the table, block
is the block handle or path, hPort
is the port handle, and hLine
is the line handle.
To run the commands on multiple ports or signal lines at once, specify these target objects as a vector of handles. To run the commands on multiple blocks at once, specify the blocks as a vector of handles or as a set of paths in a string array or cell array of character vectors.
Use Handle of This Object | Get Handle of This Object | Syntax |
---|---|---|
Block | Ports of specified block |
h = get_param(block,"PortHandles") |
Signal lines connected to specified block |
h = get_param(block,"LineHandles") | |
Port | Block to which specified port is attached |
path = get_param(hPort,"Parent");
h = getSimulinkBlockHandle(path) |
Signal lines connected to specified port |
h = get_param(hPort,"Line") | |
Signal line | Source block of specified signal line |
h = get_param(hLine,"SrcBlockHandle") |
Destination blocks of specified signal line |
h = get_param(hLine,"DstBlockHandle") | |
Source port of specified signal line |
h = get_param(hLine,"SrcPortHandle") | |
Destination ports of specified signal line |
h = get_param(hLine,"DstPortHandle") |
See Also
get_param
| Simulink.BlockPath
| Simulink.SimulationData.BlockPath
| getSimulinkBlockHandle
| Simulink.Annotation