How can I record the duration time from selecting one radio button to the other in a button group in Matlab GUI?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Kiran
2015-12-29
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dialog Boxes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!