フィルターのクリア

Getting app data into a script (old guidata)

16 ビュー (過去 30 日間)
Jeffrey Topp
Jeffrey Topp 2023 年 11 月 9 日
コメント済み: Jeffrey Topp 2023 年 11 月 10 日
I've created a GUI in App Designer which has a button that calls another script. How do I access the values of the app components from inside my script? In the guide days I would use guidata(gcf). I would rather not pass all the app component values into the script as function parameters, that would be tedious.

回答 (1 件)

atharva
atharva 2023 年 11 月 9 日
Hey Jeffrey,
I understand that you are trying to access the values of your app components from another script.
In App Designer, you can access the values of app components from within another script by using the app object. The app object represents the instance of your app, and you can use it to get or set the values of app components.
Here's an example:
1. In your App Designer, let's say you have a button with the Tag "myButton". In the button's callback function, you can call your external script and pass the app object to it.
methods (Access = private)
% Button pushed function: MyButton
function MyButtonPushed(app, event)
% Call your external script and pass the app object
externalScript(app);
end
end
2. In your external script, you can receive the app object and access the values of the components.
function externalScript(app)
% Accessing the value of a component (assuming you have a component with Tag 'myComponent')
componentValue = app.myComponent.Value;
end
By passing the app object to your external script, you have access to all the components and their values. You don't need to pass each value as a separate parameter.
This approach is more in line with the object-oriented nature of App Designer compared to the guidata method.
I hope this helps!
  1 件のコメント
Jeffrey Topp
Jeffrey Topp 2023 年 11 月 10 日
Thanks for the response. I was hoping not to run these scripts as functions as the scripts call other scripts and they populate the workspace. That's why I was going for sharing like guidata.

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by