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
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. |
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. |
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. |
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. |
Operational state of the binding, specified as a numeric or logical
1
(true
) or 0
(false
).
Examples
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 Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)