フィルターのクリア

Stop/Continue button in gui

2 ビュー (過去 30 日間)
Sagar
Sagar 2014 年 11 月 10 日
回答済み: Julia 2014 年 11 月 10 日
here is my test code for toggle button in gui,
% --- Executes on button press in togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
i=0;
while get(hObject,'Value')
disp(i);
i=i+1;
pause(2);
end
It displays 0,1,2,3...when I press toggle button it stops and when I press again the toggle button it starts displaying from first,Is there a way to continue from where it had left, I want this button to work as 'stop/continue',This is only my test code where as my original code contains many for loops,serial communication and other functions

採用された回答

Julia
Julia 2014 年 11 月 10 日
Hi,
I suggest you use i as variable in this fashion:
- declare i in the OpeningFcn:
handles.i = 0
- in the callback:
disp(handles.i);
handles.i=handles.i+1;
% Update handles structure
guidata(hObject, handles);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by