Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top