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

2 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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]');

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!