Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
datenum problem with conversion
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a question. I am trying to use datenum function as below. Question: why ans1=ans2? Am I using format wrongly? Thank you!
ans1 = datenum('4:30:00 PM','HH:MM:SS PM')
ans1 =
7.3670e+05
ans2 = datenum('2:30:00 PM','HH:MM:SS PM')
ans2 =
7.3670e+05
2 Kommentare
Stephen23
am 19 Jan. 2017
Are they the same?
>> format longg
>> datenum('4:30:00 PM','HH:MM:SS PM')
ans =
736696.6875
>> datenum('2:30:00 PM','HH:MM:SS PM')
ans =
736696.604166667
Antworten (1)
Star Strider
am 18 Jan. 2017
They’r not the same. Use the format function to display the entire number in full precision:
format long g
ans1 = datenum('4:30:00 PM','HH:MM:SS PM')
ans2 = datenum('2:30:00 PM','HH:MM:SS PM')
ans1 =
736696.6875
ans2 =
736696.604166667
1 Kommentar
Jan
am 19 Jan. 2017
Alternatively:
ans1 = datenum('4:30:00 PM','HH:MM:SS PM')
ans2 = datenum('2:30:00 PM','HH:MM:SS PM')
ans1 - ans2
% And:
(ans1 - ans2) * 86400
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!