MATLAB: Converting string matrix from Excel to Matlab

cell arraysexcelstrings

I have an excel document containing a matrix of strings (that is, each cell contains a word of varying length). If possible, I want to read this into Matlab so that I have a matrix of strings just as it is in Excel. In particular, I need to be able to reference the (i,j)th matrix element, which should contain an individual word/string.
For example, if cell A2 in excel contains "dog," I would like element (1,2) in matlab to contain the string 'dog'.
It seems like there should be a quick way to do this, but I can't get anything to work. Does anyone have any ideas? Let me know, thanks!!

Best Answer

Use XLSREAD with three outputs. The final output, raw, will contain a cell array with all of your data from Excel.
[num,txt,raw] = xlsread(filename)
A2 = raw{1,2}; % Will assign the element to variable A2
Related Question