Get values from several edit boxes using a push button in GUI?
古いコメントを表示
Hello I have a GUI to calculate a variable called S, where S=q*E*B. I want the user the enter the values of q,E and B then click a push button calculate so that the push button will display the value in a edit box called S. I think I need to use the get function but I'm not sure how to do it. Any help is much appreciated
採用された回答
その他の回答 (1 件)
Arshavin Hasegava
2020 年 7 月 17 日
0 投票
Hi
I have found a way for assigning a push button in GUI for several inputs edit text. I mean if you want to update your several variables in Workspace using only a push button, you should first to the push button callback function and then write all your variable you would like to update as follow:
x=str2double(get(handles.input1, 'string'));
y=str2double(get(handles.input2, 'string'));
z=str2double(get(handles.input3, 'string'));
then you should assign each of then to the unique "assignin'' function as follow:
assignin('base', 'x', x);
assignin('base', 'y', y);
assignin('base', 'z', z);
After runing you GUI code and enter new values in your edit textbox and then press the corresponding push button you had defined, your variables will become update in the workspace.
It is worth to note that, if you have new variable, you should first define it in your workspace.
カテゴリ
ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!