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

4 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 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]');

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by