Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can I retrieve time stored in a variable and print it next to previous time in a text file in Matlab.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am working on a time stamp code using GUI. I have four radio buttons in my interface and I want to stamp the date and start and end time when I press each radio button. This means that every time I select a radiobutton, I want that time related to it to be stored and printed as the end time of the last selected radiobutton and the start time of the currently selected radiobutton. My problem is that the endtime winds up being less than the start time and I don't know how to correct that. I would really appreciate some help. Thanks!
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
filename = 'test.txt';
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);
endtime = getappdata(0,'futuretime');
endtime = char(endtime);
%elapsedtime = char(time - prevTime);
fprintf(fileID,'%s\n',[]);
fprintf(fileID,'%s\t %s\t %s\t %s\n',A,dat,currentTime, endtime);
fclose(fileID);
setappdata(0,'futuretime',time);
0 Kommentare
Antworten (1)
Walter Roberson
am 29 Dez. 2015
You are getting your "endtime" from the existing getappdata(0,'futuretime') which was set by a previous call's current time. "endtime" is going to be in the past. You should be expecting it to be before your current time. You seem to have your past and future reversed.
1 Kommentar
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!