xlsread ERROR: Not enough input arguments
Show older comments
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
Walter Roberson
on 16 Dec 2015
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
Shashank Kumat
on 25 Feb 2016
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.
Stephen23
on 25 Feb 2016
@Shashank Kumat: try uploading it again. Click the paperclip button, then both Choose file and Attach file buttons.
Shashank Kumat
on 25 Feb 2016
Here is the same attached file, Thank you!
Walter Roberson
on 25 Feb 2016
I see the image without difficulty. Could you attach the file itself for testing?
Shashank Kumat
on 25 Feb 2016
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.
Shashank Kumat
on 25 Feb 2016
Here is the xlsread file just in case you need it
Walter Roberson
on 25 Feb 2016
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
Shashank Kumat
on 25 Feb 2016
Please find the attached .xls file. I am sorry I do not know where should I use 'which-all throw' command.
Walter Roberson
on 25 Feb 2016
At the command line, please type
which -all throw
and report the results.
Shashank Kumat
on 25 Feb 2016
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
>>
Walter Roberson
on 25 Feb 2016
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.
Shashank Kumat
on 25 Feb 2016
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.
Walter Roberson
on 26 Feb 2016
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
Shashank Kumat
on 26 Feb 2016
It did work. Now it makes me eager to know the 'science' behind it.:)
Walter Roberson
on 26 Feb 2016
Edited: Walter Roberson
on 26 Feb 2016
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.
Jus Jaisinghani
on 29 Aug 2020
I am using the suggested format but am having the problem it continues to exist.
Error using xlsread (line 257)
Not enough input arguments.
Mark
on 27 Apr 2021
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)
Scott MacKenzie
on 27 Apr 2021
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.
Answers (1)
Amir Hadi
on 25 Feb 2016
0 votes
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
Image Analyst
on 26 Feb 2016
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.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!