Binding
Connection between app components and simulation signals and variables
Since R2024a
Description
Bindings represent connections between UI components in an app and model elements
in a simulation. Use the Binding
object to modify the behavior of the
connection after you create a binding.
Creation
Create a binding by using the bind
function.
Properties
Source
— Source object
UI component | Signals
object
This property is read-only.
Source object, returned as a UI component or a Signals
object
associated with the LoggedSignals
property of a
Simulation
object. Together, the Source
and
SourceParameter
properties represent the value that updates the
binding destination.
This table describes the valid source object and source parameter pairs.
Source Object | Source Parameter | Result |
---|---|---|
UI component, such as a Slider or
Label object | Property name, such as 'Value' | When the specified property of the UI component changes (interactively or programmatically), the destination object updates. |
Signals object associated with the
LoggedSignals property of a Simulation
object | Block path and port index of a logged signal, such as
'myModel/Velocity:1' | When the specified signal logs data, the destination object updates. |
SourceParameter
— Source parameter
character vector
This property is read-only.
Source parameter, returned as a character vector. Together, the
Source
and SourceParameter
properties
represent the value that updates the binding destination.
This table describes the valid source object and source parameter pairs.
Source Object | Source Parameter | Result |
---|---|---|
UI component, such as a Slider or
Label object | Property name, such as 'Value' | When the specified property of the UI component changes (interactively or programmatically), the destination object updates. |
Signals object associated with the
LoggedSignals property of a Simulation
object | Block path and port index of a logged signal, such as
'MyModel/Velocity:1' | When the specified signal logs data, the destination object updates. |
Destination
— Destination object
UI component | Variables
object
This property is read-only.
Destination object, returned as a UI component or a Variables
object associated with the TunableVariables
property of a
Simulation
object. Together, the Destination
and
DestinationParameter
properties represent the value that is
updated when the binding source changes.
This table describes the valid destination object and destination parameter pairs.
Destination Object | Destination Parameter | Result |
---|---|---|
UI component, such as a Slider or
Label object | Property name, such as 'Value' | When the binding source changes, the specified property of the UI component updates. |
Variables object associated with the
TunableVariables property of a
Simulation object | Variable name, such as 'myVar:MyModel' | When the binding source changes, the specified model variable updates. |
TimeScope UI component object | '' | This destination can be used only when the source is a logged signal. When the signal logs data, the time scope updates to display the data. |
DestinationParameter
— Destination parameter
character vector
This property is read-only.
Destination parameter, returned as a character vector. Together, the
Destination
and DestinationParameter
properties represent the value that is updated when the binding source changes.
This table describes the valid destination object and destination parameter pairs.
Destination Object | Destination Parameter | Result |
---|---|---|
UI component, such as a Slider or
Label object | Property name, such as 'Value' | When the binding source changes, the specified property of the UI component updates. |
Variables object associated with the
TunableVariables property of a
Simulation object | Variable name, such as 'myVar:MyModel' | When the binding source changes, the specified model variable updates. |
TimeScope UI component object | '' | This destination can be used only when the source is a logged signal. When the signal logs data, the time scope updates to display the data. |
Enabled
— Operational state of binding
true
or 1
(default) | false
or 0
Operational state of the binding, specified as a numeric or logical
1
(true
) or 0
(false
).
Examples
Modify Binding After Creation
Create a slider in a UI figure.
fig = uifigure; sld = uislider(fig,Limits=[-1 0],Value=-0.8);
Create a Simulation
object that represents a simulation of the bouncingBall
model.
s = simulation("bouncingBall");
Connect the slider value to a variable in the model by creating a binding, and specify that the binding is created in a disabled state. Store the Binding
object in a variable, b
, so you can modify the binding after creation.
vars = s.TunableVariables; varname = "K:bouncingBall"; b = bind(sld,"Value",vars,varname,Enabled=false);
Enable the binding by setting the Enabled
property of b
using dot notation.
b.Enabled = true;
Delete the binding using the delete
function.
delete(b)
Version History
Introduced in R2024a
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)