Toggle Button [Start,Stop, Resume......... Finished]

7 次查看(过去 30 天)
Helo!!
I am making a gui that will display a moving ecg plot and I need to control the movement with a toggle button. At first it will say Start and it will start the plotting. Then it will say stop and when pressed it will pause the plotting. If button is pressed again it will resume from where it left off and so on. I am having trouble with this last part of making it resume from where it left off. I really need help. Bellow is my code so far. Thank you in advance.
function togglebtn_Callback(hObject, eventdata, handles)
% hObject handle to togglebtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load mit200
wLen=600; %window length
ecgsigfiltered=movmean(ecgsig,20);
tb_state = get(hObject,'Value');
sigLen=length(ecgsigfiltered);
counter=1:sigLen-wLen;
for i=counter
if tb_state == get(hObject,'Max') % toggle button is pressed
set(handles.togglebtn,'String','Stop');
axes(handles.ecgSignal_axes);
plot(tm(i:wLen+i-1),ecgsigfiltered(i:wLen+i-1),'.b');
axis([tm(i) tm(wLen+i-1) -2.5 2.5 ]);
title('ECG Signal');
xlabel('Time(sec)');
ylabel('Amplitude(mV)');
grid on;
box on;
pause(0.05);
elseif tb_state == get(hObject,'Min')
set(handles.togglebtn,'String','Resume');
uiwait;
end
end
guidata(hObject,handles);
set(handles.togglebtn,'String','Finished');

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 ECG / EKG 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by