how to show miliseconds in a date string?

조회 수: 5 (최근 30일)
Camilo Andrés Roca Duarte
Camilo Andrés Roca Duarte 2011년 5월 23일
Hi everyone I am trying to generate an array of date strings in Matlab, but I need to see the miliseconds in the string. I havent found the correct format to do that, if anyone knows how to do that, please tell me.
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 23일

Include 'FFF' in the date specifier for datestr()

http://www.mathworks.com/help/techdoc/matlab_prog/bspgcx2-1.html#bsplnu3-2

  댓글 수: 1
Jan
Jan 2011년 5월 23일
+1: DATESTR has an excellent error checking and accepts a variety of input formats. If the date conversion is not a bottleneck of the program, this is an efficient method.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2011년 5월 23일

MATLAB's date functions are very powerful, but this reduces their speed. If the dates need no verifications, because they have the correct format already, a direct approach is much faster. E.g. DATEVEC to dd-mmm-yyyy HH:MM:SS.FFF:

In = clock;
months = ['Jan'; 'Feb'; 'Mar'; 'Apr'; 'May'; 'Jun'; ...
          'Jul'; 'Aug'; 'Sep'; 'Oct'; 'Nov'; 'Dec'];
Out = sprintf('%.2d-%s-%.4d %.2d:%.2d:%06.3f', ...
              In(3), months(In(2), :), fix(In([1, 4, 5])), In(6));

If speed does not matter for this task, I recommend Walter's DATESTR+'FFF' method.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by