Interrupt running function with event in a GUI
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi, I want to use a GUI pushbutton to signal an event to a running function - in particular, to issue the 'keyboard' command in a misfit function which is being called by fminsearch (to investigate the state of the fitting process). Currently I use the following: Before calling fminsearch, main script opens a small GUI with a pushbutton with callback:
function pushbutton1_Callback(hObject, eventdata, handles)
global interrupt
interrupt=true;
...and in the misfit function:
global interrupt
%...
if interrupt, keyboard, interrupt=false; end
This works, but I have to hammer the pushbutton repeatedly to get a response (waiting after one push doesn't seem to work). There is already a drawnow command in the misfit function on each call, which apparently should allow Matlab to process outstanding events, but this does not seem to improve matters (neither does a pause(0.01)).
Can someone suggest a good way to do this which might be more responsive?
댓글 수: 2
Geoff Hayes
2016년 1월 31일
Mark - what else is the misfit function doing (is this something that you have written)? Perhaps it is "busy" and once it finishes evaluating whatever it is doing, then it checks the interrupt flag. Please post the code for this function (or an outline of it) so that we can get a better idea of what may be causing the delay.
답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!