0
votes

I import a sheet from Excel into matlab using the command "readtable":

TABLE = readtable(Excel.FN, 'sheet', Excel.Sheet);

The table contains both, numeric values and strings. If I try to access the numeric values, I can't get them as double.

TABLE{j,i} = '0.00069807'

is still a cell.

cell2num(TABLE{j,i}) = NaN   
cell2mat(TABLE{j,i}) = 0.00069807,

but this is a char. So I use

str2num(cell2mat(TABLE{j,i}))

to obtain the numeric value. There must be a simpler way. Could you please tell me the command.

1
Have you tried using xlsread ? You can store the numbers and text into separate variables that's quite handy. Otherwose you might want to try str2double, it operates on cell arrays - Benoit_11

1 Answers

0
votes

If you don't insist on readtable, the xlsread would be better for you. Loaded data are more "matlab-friendly" with this function.

I am not sure whether there is a simpler solution with readtable. I think that's just the price you need to pay for not working with the "rawer" data such as CSV or simple text files.