How to control button in GUI Start and Stop process

when I press stop button process is stop all and when press start button again process is begin again

1 件のコメント

Gopichandh Danala
Gopichandh Danala 2017 年 6 月 20 日
provide more details, we don't understand like what to start or stop lot of assumptions

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

 採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 20 日
編集済み: Walter Roberson 2017 年 6 月 20 日

2 投票

There is no way to use the GUI to interrupt a routine without its cooperation.
Your stop_Callback should set a value in a shared area. Your realtimefunction routine should sometimes fetch the current version of the value, and exit if it finds it has been asked to stop.
For example,
function start_Callback(hObject, eventdata, handles)
set(hObject, 'UserData', false);
realtimefunction(handles);
function stop_Callback(hObject, eventdata, handles)
set(handles.start, 'UserData', true);
function realtimefunction(handles)
...
while true
drawnow(); %give a chance for interrupts
need_to_stop = get(handles.start, 'UserData');
if ~isempty(need_to_stop) && need_to_stop;
break;
end
...
end
%now clean up as needed

9 件のコメント

Adisorn Phanukthong
Adisorn Phanukthong 2017 年 6 月 20 日
How can I do it anything else? follow in your code?
Walter Roberson
Walter Roberson 2017 年 6 月 20 日
You currently have
function realtimefunction(handles)
and it must already loop around getting new data and processing it. I show here how you can have the stop button set an indicator that you want to stop, and I show here how to have the realtimefunction check that indicator. This should be a minor change to the code you already have.
Adisorn Phanukthong
Adisorn Phanukthong 2017 年 6 月 20 日
right?
Walter Roberson
Walter Roberson 2017 年 6 月 20 日
Post your original code for function realtimefunction
Adisorn Phanukthong
Adisorn Phanukthong 2017 年 6 月 20 日
編集済み: Adisorn Phanukthong 2017 年 6 月 20 日
this is realtime function
Walter Roberson
Walter Roberson 2017 年 6 月 20 日
Adjusted code enclosed. I did not attempt to debug your classification code.
Note: I did, however, follow the comment in the code that said it had to stop after 100 frames; I added in appropriate variables to do that. I did that in addition to adding in the code for the stop button, so the routine will stop if it reaches 100 frames or if the stop button is pushed.
Your code reads two frames each time, so 100 frames is 50 iterations of the loop. I cannot see any good reason for the code to read 2 frames each time: I think you should be reading 1 frame at a time and comparing to the immediately preceding frame instead of reading pairs of frames and computing the second one relative to the first of the pair.
Adisorn Phanukthong
Adisorn Phanukthong 2017 年 6 月 20 日
stop when find A twice program is stop process
Walter Roberson
Walter Roberson 2017 年 6 月 20 日
That is not what the comments say. As you inform me that you are having problems executing the code, I must presume that the comments describe the way that the code is intended to operate and that any code that does not work that way is incorrect code that you were asking me to repair.
In any case you can easily remove the test I put in about framecount < 100
Zeljko Tomicevic
Zeljko Tomicevic 2018 年 1 月 13 日
Hello,
Have the same problem but I did not catch nothing from above. Where I can read more about starting and stopping real time functions in APP designer?
Best

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

その他の回答 (1 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by