MATLAB: How can i separate strings in cell like {‘3m’,’cm’} to number 3, char m and string cm

cell arrayconverthelpstring

how can i separate strings in cell like {'3m','cm'} to number 3, char m and string cm?
in the end i want to convert the first number in the first cell by the unit in the first cell after the number to the number in the unit in the second cell.
like 3 meter to 300 cm.
thanks

Best Answer

Experimenmt with the regexp (link) function:
c = {'3m','cm'};
r = regexp(c, '\d*|\w*', 'match');
r1 = r{1}
r2 = r{2}
producing:
r1 =
1×2 cell array
{'3'} {'m'}
r2 =
1×1 cell array
{'cm'}