%% Specify Input Format of Text
% Specify the format of text representing elapsed times, and then convert them to duration arrays.
% Convert a character vector. The input format represents minutes and seconds. The output argument is a duration value, whose format represents hours, minutes, and seconds.

T = '78:34';
infmt = 'mm:ss';
D = duration(T,'InputFormat',infmt)

%
% Create a cell array of character vectors whose format represents minutes, seconds, and fractions of a second to three decimal places.

infmt = 'mm:ss.SSS';
T = {'1:34.862' '67:07.218'}

%
% Convert T to a duration array. Specify that the format of the duration array represents hours, minutes, seconds, and fractions of a second.

outfmt = 'hh:mm:ss.SSS';
D = duration(T,'InputFormat',infmt,'Format',outfmt)

% Copyright 2012 The MathWorks, Inc.