What other option similar to tic/toc can be used for a time stamp program in GUI?
Show older comments
Hello, I have finally got my timestamp program working. I am using tic/toc to register the time that goes between selecting radiobuttons. The program runs fine. However, if I close matlab and I open it again it doesn't run anymore and a message shows that tic has to go before toc with no output arguments. I was wondering if you guys can help me fix this, any other alternatives?
Thanks!
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
% This is the radio button function that stores name, date and times of
% each selected button.
global filename;
fileID = fopen(filename,'at');
A = get(hObject,'String');
date = datetime('now','Format','MM/dd/yyyy');
dat = char(date);
time = datetime('now','Format','HH:mm:ss');
currentTime = char(time);
elapsedtime = datestr((toc/24/3600),'HH:MM:SS');
fprintf(fileID,'Event ends:\t %s\t %s\t Event duration:\t %s\t \n',dat,currentTime,elapsedtime);
fprintf(fileID,'%s\n',[]);
fprintf(fileID,'%s\t %s\t %s\n',A,dat,currentTime);
fclose(fileID);
persistent count
if isempty(count)
count = 0;
end
count = count + 1;
if count > 0
tic;
end
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB 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!