Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How can I retrieve time stored in a variable and print it next to previous time in a text file in Matlab.
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2015 年 12 月 29 日
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 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!