Is there a format option for the DATESTR function within the Financial Toolbox that shows fractions of seconds?

조회 수: 4 (최근 30일)
I have several data points within one second, and I would like to show the fractional parts of the second rather than rounding off to the nearest second as all the DATESTR formats do.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
This enhancement has been incorporated in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
The ability to do use a DATESTR format that does not round-off the seconds is not available in MATLAB.
To work around this issue, you can customize the following function to suit your specific needs:
function out = newdatestr(T)
% This function converts a time, T, from the DATENUM format into
% HH:MM:SS.SSSSSS
%
% Here the seconds part retains 6 digits past the decimal. To change
% this number, change the number after the decimal after
% the last percent in the format string "f".
[y,mo,d,h,min,s] = datevecmx(T, 6);
f = '%2d:%2d:%2.6f\n';
out = sprintf(f, [h, min, s]');

추가 답변 (0개)

카테고리

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