2

I'm trying to read some data stored in a .xlsx file into MATLAB. However, using xlsread returns an empty data set.

data = xlsread('myFile.xlsx');

The sheet name is the standard 'Sheet1', so I know it's not looking for the wrong sheet.

I even checked to make sure the file exists, and went as far as to use uigetfile to ensure the path and string names are correct:

[fileName,dirName]=uigetfile('.xlsx');
data = xlsread(fullfile(dirName,fileName));

What am I doing wrong?

Amro
  • 123,847
  • 25
  • 243
  • 454
Doresoom
  • 7,398
  • 14
  • 47
  • 61

1 Answers1

5

xlsread only returns numeric data when only one output is specified. If the .xlsx file contains only text data, it will return empty. To remedy this, specify the outputs:

[fileName,dirName]=uigetfile('.xlsx');
[~,~,rawData] = xlsread(fullfile(dirName,fileName));

will return the entire contents of the sheet without MATLAB parsing the results and deciding what's text and what's numeric data.

Doresoom
  • 7,398
  • 14
  • 47
  • 61
  • 2
    you might also be interested in this: http://undocumentedmatlab.com/blog/xlsread-functionality-change-in-r2012a/ – Amro Aug 09 '13 at 15:52
  • @Amro: Good tip. I thought I'd post this Q&A for anyone else experiencing the same brain lapse that cost me 15 minutes of very frustrated troubleshooting. – Doresoom Aug 09 '13 at 18:53