How can I record the duration time from selecting one radio button to the other in a button group in Matlab GUI?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi there,
I am working on a time stamp project to record events with dates and times linked to radio buttons. I created a button group with four radio buttons and I was able to stamp the event(name) of each radio button, the date and the start time of such event when I press the first radio button. What I want is that when I press the next radio button, the new start time of the new radio button pressed also gets recorded as "end time" of the previous radio button. I am storing this info in a text file. The last part that starts with d = clock is the "end time" that is not working correctly. My code looks like this:
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
filename = 'conditiontimes1.txt';
fileID = fopen(filename,'at');
%This gets and stores start date and time of an event
A = get(hObject,'String');
c = clock;
date = c;
formatOut = 'mmm/dd/yyyy';
dat = datestr(date,formatOut);
time = c;
timeOut = 'HH:MM:SS';
tim = datestr(time,timeOut);
%I want to get and store the end time of the previous event when pressing
%new radio button
d = clock;
time2 = d;
tim2 = datestr(time2,timeOut);
fprintf(fileID,'%s\t %s\t %s\t %s\n',A,dat,tim,tim2);
fclose(fileID);
THank you very much for your help!
0 Kommentare
Antworten (1)
Kiran
am 29 Dez. 2015
One of the possible solution to your query could be storing "clock" variable as a apps data, by "setappdata", and pass it in callback function. First call to callback function would store the starttime while second call would store endtime to the file.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!