why reading .xls file using xlsread returns empty variables?

Hello
I have some data in a .xls file. the file content is four colunms. the first row is a header then all others are numbers.
I tried to simply use
[ndata, text, alldata] = xlsread(filename)
but it does not return anything
ndata =
[]
text =
0×0 empty cell array
alldata =
1×1 cell array
{[NaN]}
How can I solve this problem?
Thanks!

4 件のコメント

KSSV
KSSV 2020 年 11 月 20 日
Try readtable.
Nora Khaled
Nora Khaled 2020 年 11 月 20 日
same problem
0×0 empty table
Mathieu NOE
Mathieu NOE 2020 年 11 月 20 日
can you share your excel file ?
Nora Khaled
Nora Khaled 2020 年 11 月 20 日
Thank you!
your comment made me realize the problem.
The problem is the data is not in the first sheet of the .xls file.

サインインしてコメントする。

 採用された回答

Nora Khaled
Nora Khaled 2020 年 11 月 20 日

0 投票

The problem is the data is not in the first sheet of the .xls file.
I needed to sort the xls sheets before using
[ndata, text, alldata] = xlsread(filename)

3 件のコメント

Mathieu NOE
Mathieu NOE 2020 年 11 月 20 日
you can specify the sheet you want to read
read the help
% Read from a named worksheet:
B = xlsread('myExample.xls', 'MySheet')
Peter Perkins
Peter Perkins 2020 年 11 月 20 日
Also, KSSV's recommendation to use readtable instead of xlsread is still worth heeding.
Mathieu NOE
Mathieu NOE 2020 年 11 月 20 日
yes sure
it's because I'm older and I'm always using "old" functions , but I'm improving lately on new stuff

サインインしてコメントする。

その他の回答 (0 件)

質問済み:

2020 年 11 月 20 日

コメント済み:

2020 年 11 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by