如何在MATLAB中将字符串分隔成不同的列?

时间:2013-05-12 21:42:53

标签: arrays matlab

如何隔离ddmmyyhhmmssdaymonthyearhourminutesecond)12位数编号并放在MATLAB的单独6列中?我现在总共需要7列。例如,我有以下字符串

051210151255 (which is 05 day, 12 month, 2010 year, 15 hours, 12 minute, 55 second)

现在我需要7列(whole 12 digit number, dd, mm, yy, hh, mm, ss

1 个答案:

答案 0 :(得分:0)

d = '051210151255';
output = zeros(1, 6);
for i=1:6
   output(1, i) = str2num(d(i*2-1:i*2));
end
output = [str2num(d) output];

给出:

>> output =

     051210151255 5    12    10    15    12    55