What other option similar to tic/toc can be used for a time stamp program in GUI?
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!