MATLAB: How to convert cell into array of floating point numbers only

arraycellfloating point

I have a 64×1 cell will contents as follows:
'1 mA'
'1.2 mA'
'1.4 mA'
'1.6 mA'
'2 mA'
...
I would like to convert it into an array of floating point numbers – excluding the letters mA. Many thanks, S

Best Answer

splitStrings = cellfun( @(x) strsplit( x, ' ' ), myCell, 'UniformOutput', false );
vals = cellfun( @(x) str2double( x{1} ), splitStrings );
should work assuming your data is always in that format without anything more complicated, though there are probably neater ways.