Getting data from a GUI

Hi,
I have a GUI set up, but i want to use the input from this data in a seperate function (called 'Atps') which is not my main. Is there a way i can get the variable out of the GUI function and into Atps?
Thanks in advance

5 件のコメント

Adam
Adam 2019 年 7 月 29 日
Call Atps from a callback on your GUI, e.g. a 'Run' button, and pass in all the relevant data that you extract from the graphic object handles.
KatherineS
KatherineS 2019 年 7 月 29 日
Thank you for your answer.
How exactly would i do this? Sorry Im really new to all this!
Adam
Adam 2019 年 7 月 29 日
You can access all your GUI components by their tags. It will be different depending how you created the GUI. But e.g. in GUIDE you can put
param1 = str2double( get( handles.editParam1, 'String' ) );
param2 = get( handles.sliderParam2, 'Value' );
etc
in a 'Run' button callback, which you create just by adding a button and going to its callback.
Then you call your function as you would from anywhere else once you have its inputs, e.g.
Atps( param1, param2 )
or whatever you need to pass in.
KatherineS
KatherineS 2019 年 7 月 29 日
Thank you for your reply, I get the error message "Dot indexing is not supported for variables of this type" when using this, is there any way to solve it?
Adam
Adam 2019 年 7 月 30 日
It depends where you are getting the error and on what. The only place I use dot indexing above is on handles, which, if you are in a callback in GUIDE, should be a struct. If you aren't in GUIDE then you need to get hold of your components in a different way.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

製品

リリース

R2019a

質問済み:

2019 年 7 月 29 日

コメント済み:

2019 年 7 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by