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!