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
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