textscan not reading file properly

Asked by Benson about 9 hours ago
Latest activity Commented on by per isakson about 7 hours ago

I have used textscan successfully in this manner for other files (different file extension). I am not sure why it does not work for this excel sheet (.xlsx). It is telling me that M = [0x1 double] [0x1 double].

http://img14.imageshack.us/img14/4594/b830.png

clear
fid=fopen('data.xlsx');
M = textscan(fid,'%n%n')
fclose(fid);

Any help is appreciated. Thanks!

2 Comments

Walter Roberson about 7 hours ago

Which MATLAB release are you using, and which operating system? If you are on MS Windows, which version of Excel do you have installed ?

per isakson about 7 hours ago

textscan cannot read an xlsx-file. It isn't text.

Benson

Products

No products are associated with this question.

2 Answers

Answer by Azzi Abdelmalek about 9 hours ago
M=xlsread('data.xlsx');

2 Comments

Benson about 9 hours ago

I have tried that, but I get "Unable to read XLS file C:\Users\Benson\Desktop\Princeton13 Documents\ECData\data.xlsx. File is not in recognized format."

I have also tried editing the file extension to data.xls, but I get the same error.

per isakson about 7 hours ago

Open and close the file with Excel.

Azzi Abdelmalek
Answer by per isakson about 7 hours ago
Edited by per isakson about 7 hours ago

Could it be that the cells in Excel are defined as right-justified text? Try

    [num,txt,raw] = xlsread('data.xlsx')

and inspect all three outputs.

Which versions of Excel and Matlab do you use?

0 Comments

per isakson

Contact us