I have strings that look like this: '24:06:26' and '7:20:26'. I want a duration type. What is the best way to get this?
All I have right now is
str = ' 7:20:26' % or '24:06:26'
d = duration(cellfun(@(x) str2double(x), regexp(str,'\d{1,2}','match')));
This seems inefficient and overkill because I have to use at least 3 function calls to get to a duration type.
Best Answer