Pausing the program for GUI

조회 수: 3 (최근 30일)
JA
JA 2016년 7월 19일
댓글: Adam 2016년 7월 19일
i have a code which does some calculation, then calls the GUI. In the GUI i have some options for user to select from. based on that answer, further calculation is done.
Function this = random(this)
...some calc
...some calc
...some calc
...some calc
GUI % calls the GUI
value = getappdata(0,'value') %gets the value from the GUI
...some calc
...some calc
end
the problem is when I compile, it calls the GUI and continues with the program. how do i make the program wait until a button is pressed in the GUI?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 19일
Use waitfor function
  댓글 수: 6
JA
JA 2016년 7월 19일
편집: JA 2016년 7월 19일
I created them with GUIDE.
% --- Executes on button press in Apply.
function Apply_Callback(hObject, eventdata, handles)
% hObject handle to Apply (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
value = get(handles.slider1,'Value');
setappdata(0,'final_value',value)
close()
this is my callback function of the button
Adam
Adam 2016년 7월 19일
But when you actually initialise the GUI, you can call it as e.g.
hGUI = MyGui;
to get the handle of the GUI, then use this with waitfor.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by