How can I push simultaneously two toggle buttons without stopping the execution of one button in Matlab GUI

2 views (last 30 days)
Hello,
I'm quite new in using Matlab Guide and I've a question. I'm trying to create a simple interface of data encoding. The goal of the interface is to fill in a matrix with 0 and 1 when an activity is done or not in a video file. Obviously, when we push a button, then the value 1 appears in the storage matrix. So in Guide, I defined a zero matrix, I create toggle buttons for activities, so for each activity (i.e. each button), I put this code:
% --- Executes on button press in Grazing_start.
function Activity1_start_Callback(hObject, eventdata, handles)
% hObject handle to Activity1_start (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 the togglebutton
time = handles.time; %time in seconds, initially time = 1%
be=handles.be; % be is a zero matrix initially
a=get(hObject,'Value');
while a==true
be(time,2)=1;%If I'm pushing the Activity1 button, then put 1 in the 'be' matrix
time=time+1;
handles.time=time;
handles.be=be;
guidata(hObject,handles);
pause(1) %stop every 1 second for the timer
if ~get(hObject,'Value')
break
end
end
guidata(hObject,handles);
While 'be' is the zero matrix I initialized at the beginning of the GUI. So I want to store the executed activities, marked by the value 1, in the matrix 'be'. My problem is that: when I push two buttons simultaneously, as two activities could occur at the same time, nothing is working. What should I change? Or how is the best way to fill this matrix relative to time?
Thanks to all.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!