www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ChangeDisplayFormatOfDurationValuesExample.m

    %% Change Display Format of Duration Values
% Group duration values by hour and return the result in a variety of
% display formats.
%
% Group some random duration values by hour and return the results as a
% categorical array.
X = hours(abs(randn(1,10)))'

%%
Y = discretize(X,'hour','categorical')

%%
% Change the display of the results to be a number of minutes.
Y = discretize(X,'hour','categorical','m')

%%
% Change the format again to display as a number of hours, minutes and
% seconds.
Y = discretize(X,'hour','categorical','hh:mm:ss')