How to use default component value as variable in assignin()

3 ビュー (過去 30 日間)
Antony
Antony 2022 年 8 月 29 日
回答済み: Divyam 2025 年 4 月 30 日
I've added components to an app and set default values for some of them. How does one access these default values in order to use them in assignin() such that it is unnecessary to change them or write over them in the UI?
  1 件のコメント
dpb
dpb 2022 年 8 月 29 日
Think we'll have to see some code to illustrate what, specifically, you're talking about...I've set default values on UI in app's and never run across a need for assignin so having hard time imagining what you must be trying to do here.

サインインしてコメントする。

回答 (1 件)

Divyam
Divyam 2025 年 4 月 30 日
Hi @Antony,
The default value for the components of your App can be accessed via the '.Value' property of the component. If you don't change the value in the UI, the '.Value' property will reflect the default value set for the component.
To access this default value in the base workspace as soon as the App launches, you can add a 'startupFcn' callback in your app that runs the following code:
% Assuming that the component used in UI is an Edit Field
function startupFcn(app)
assignin('base', 'editValue', app.EditField.Value);
end
For more information regarding 'startupFcn' callback, refer to the following documentation: https://www.mathworks.com/help/matlab/creating_guis/app-designer-startup-function.html

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by