Convert a cell array using str2double

Hi all,
I am trying to convert the following cell array statements into a matrix. Using str2double is giving 'NAN'. and cell2mat is throwing an error as "Dimensions of arrays being concatenated are
not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});"
Any help is appreciated. Thanks
'9, 1., 0.514999986'
'10, 0., 0.514999986'
'11, 1., 0.75'
'12, 0., 0.75'
'13, 0., 0.649999976'
'14, 1., 0.649999976'
'15, 1., 0.25'
'16, 0., 0.25'
'17, 0., 0.'
'18, 1., 0.'
Bharat

 Accepted Answer

C={'9, 1., 0.514999986'
'10, 0., 0.514999986'
'11, 1., 0.75'
'12, 0., 0.75'
'13, 0., 0.649999976'
'14, 1., 0.649999976'
'15, 1., 0.25'
'16, 0., 0.25'
'17, 0., 0.'
'18, 1., 0.'}
cell2mat(cellfun(@str2num,C,'uniform',0))

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!