views:

43

answers:

2

I would like to read strings into Matlab from an excel file

ID = xlsread('data.xlsx',1, 'D2:D4')

the cells in range D2:D4 have strings in them. When I try to import the strings into Matlab all I get is an empty list? what can I do to fix this?

+3  A: 

I need to use this [num, txt, raw] = xlsread('data.xlsx',1, 'D2:D4')

the txt will import stings into Matlab.

Ben Fossen
+4  A: 

If you're in Matlab 2010 you can also do something like this to avoid having extra values in your workspace.

[~, ~, raw] = xlsread('data.xlsx',1, 'D2:D4')
JudoWill
The 3-argument output is available in older versions as well; I'm not sure how far back it goes.In my experience, the raw output is superior to using the [num,txt] outputs because MATLAB "helpfully" discards non-numeric header rows and/or columns around the edges of the num output.
Arthur Ward
By the "in matlab 2010" I meant using `~` as a way of specifying an output but not actually naming any variables ... in the other example `[num, txt, raw] = xlsread('data.xlsx',1, 'D2:D4')` you will have an extra `num` and `txt` variable in your workspace.
JudoWill