Matlab - Why sometimes xslread doesn't let use a number as a sheet argument?

Viewed 1249

I want to read an excel file with 10 sheets with matlab with the xlsread function like this:

SPLByFrequency = zeros(173, 10);
for i = 1:10
    rawData = xlsread('mediciones', i);
    SPLByFrequency(:, i) = rawData(84:256, 3);
end

It's not the first time I read excel sheets using a number as argument and I've never had any problem but this time it doesn't let me do it and I get this error:

Error using xlsread (line 207)
In basic mode, sheet argument must be a string.

Error in TareaB53 (line 11)
    rawData = xlsread('mediciones', i);

I haven't been able to change this 'basic' mode and doing some debugging I've found that, strangely enough, xlsread('mediciones', 1) works but it doesn't work with any other number.

Doing some research I've found there is a way to escape from this problem by using xlsinfo to get the sheet names and then use the sheet strings as an argument but I don't understand why I couldn't do it simply directly with a number, why I can do it just with the number 1 or why it suddenly doesn't work while I've always been doing it with a number as an argument.

Is there a way to solve this and use directly a number as a sheet argument?

Edit - Summary and new information

If you don't have Excel for Windows installed, xlsread operates in basic mode so you cannot use a number for the sheet argument.

Therefore, for portability, it would be better to use xlsinfo to get the sheet strings.

For some reason, even if it seems it isn't supposed to, (for me) it worked on OS X 10.9. However, it doesn't work anymore on OS X 10.11 (I have Matlab release 2012a).

1 Answers
Related