Suppose we have a Time sting (h)h:mm:dd. in 12 hr format. This will cause some trouble when attempting to construct a column vector in Matlab because the difference of the length. It is of course very easy to address this problem by testing whether the length of the string is 8 or 7 and pad blank at the front.
Another way is to use regular expression.
Suppose we have Time T1 = '1:30:20' and T2 = '12:20:40'
regexprep(T1,'^\w:',...
'${strcat(num2str(str2num($&(1))+12),'':'')}')
yields 13:30:30
evaluating on T1 yields 12:20:40
No comments:
Post a Comment