Reputation: 543
'10004_1' '01:27:29' '27' 'Uncertainty' ''
'10004_2' '02:03:10' '3:29' 'Neutral' ''
'10004_3' '01:01:01' '5:31' 'Neutral' ''
'10004_4' '01:10:02' '1:16' 'Neutral' ''
I have above sample data and these "%%:%%:%%" format data needed to be processed in the following way.
i.e. 01:27:29 => (((1*60+27)*60)+29)*30 which would be a numeric value.
I tried using cellfun, and the function used in cellfun would split the string with ':', and make the calculation. Maybe some other ways. Newbie to Matlab, really no clue. In the meantime, I will try the function to see if would work. Please feel free to let me know your thoughts or sample codes. Appreciate this.
Upvotes: 0
Views: 62
Reputation: 1787
text = '01:23:12';
nums = textscan(text, '%d:%d:%d');
rst = (((nums{1} * 60 + nums{2}) * 60) + nums{3}) * 30;
Upvotes: 2