Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
datenum problem with conversion
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Stephen23
el 19 de En. de 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
Respuestas (1)
Star Strider
el 18 de En. de 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 comentario
Jan
el 19 de En. de 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
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!