Your example indicate that you want to convert these string numbers to numeric, and then collect the runs of one value together into one element. This is easy using diff:
>> C = {'1 1 1 1 1 32','29 7 1 1 2 2 2 1 1 29'};
>> D = cellfun(@(s)sscanf(s,'%f'),C,'UniformOutput',false);
>> E = cellfun(@(v)v([true;diff(v)~=0]),D,'UniformOutput',false);
>> E{:}
ans =
1
32
ans =
29
7
1
2
1
29
Best Answer