xlsread ERROR: Not enough input arguments

Hi, I used the following line of code below to import an Excel file using xlsread.
nbaData = xlsread('nbasal.xls');
Initially it worked and the command imported the Excel file correctly. I stopped working and came back to my project a few hours later and started receiving the following error message:
>> nbaData = xlsread('nbasal.xls')
Error using xlsread (line 251)
Not enough input arguments.
I did not change the name of the file, the location of the file, or any data in the file. I have restarted Matlab multiple times and still receive the same error. Not real sure what is going on.
Any help or suggestions would be much appreciated. Thanks

19 Comments

At the MATLAB command line, command
dbstop if error
and run the code again. When it stops with the error, please show the line of code it is executing inside xlsread.
Is it possible that you named your code xlsread.m or otherwise created your own xlsread.m ?
which -all xlsread
Hey, I was trying the same, but I tried to re- run the program after a few days and I got this error. I am attaching the screenshot of the error line. May be you could help me out. Thank you.
@Shashank Kumat: try uploading it again. Click the paperclip button, then both Choose file and Attach file buttons.
Here is the same attached file, Thank you!
I see the image without difficulty. Could you attach the file itself for testing?
May be if you try to click the zoom in pointer that appears on the screen when you click the image file, that should help you out.
Here is the xlsread file just in case you need it
I meant the .xls file ;-)
Please use
which -all throw
to see where it is looking for throw since that is what appears to be on line 251
Please find the attached .xls file. I am sorry I do not know where should I use 'which-all throw' command.
At the command line, please type
which -all throw
and report the results.
Enter the sheet number in MDH excel file you want to read:
2
Error using xlsread (line 251)
Error in Forward_Kinematics_program (line 7)
[num,txt,raw]=xlsread(data,sheet);
>> which -all throw
throw is a built-in method % MException method
C:\Program Files\MATLAB\R2015b\toolbox\matlab\lang\@MException\throw.m % MException method
>>
I notice that mdhtable.xlsx is not the same file name or file extension as nbasal.xls from your error message. That could be important: there could be a binary format problem with the nbasal.xls file that does not show up with the mdhtable.xlsx version.
Well, I think I am confused now. in my program I have used mdhtable.xlsx where as @Christopher DeCarlo used nbasal.xls. But still I have the same error as he has and that too when I ran my program after a couple of days.
Shashank, experiment with
[num, txt, raw] = xlsread('mdhtable.xlsx', 2, '', 'basic')
Note: I would not expect that to work for .xls but I would expect it to potentially work for .xlsx
It did work. Now it makes me eager to know the 'science' behind it.:)
Using 'basic' mode invokes internal code to read the file, whereas otherwise you are launching Excel to read the file, so if Excel gives a problem then it can be difficult to track down the reason.
I am using the suggested format but am having the problem it continues to exist.
Error using xlsread (line 257)
Not enough input arguments.
I had this problem -- had downloaded an .xlsx file from lab file share and for whatever reason was getting the "not enough input arguments" error as above. I opened the file in Excel, re-saved it (again as .xlsx, overwriting the old file), and then xlsread was happy. (MacOS, 2020b)
Seems you are excuting from the command prompt. The error is at line 251 which is within the code for the function.
Try putting this in a script and executing the script to see if the behaviour is different.
Finally, xlsread is no longer recommended. Try using readmatrix or readtable.
Just my two cents. Good luck.

Sign in to comment.

Answers (1)

I also get this error...
the code is simple Data = xlsread('project.xlsx') but it gives me the following error:
Error using xlsread (line 251)

1 Comment

This is not an Answer that is useful to Christopher. Please post your question in your own new Question, and be sure and post all the red text, not just a small snippet of it like you did here. Also attach the workbook.

Sign in to comment.

Asked:

on 16 Dec 2015

Commented:

on 27 Apr 2021

Community Treasure Hunt

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

Start Hunting!