Error using .xlsread

7 views (last 30 days)
Kareemulla Dudekula
Kareemulla Dudekula on 1 Nov 2023
Answered: Yash on 2 Jan 2024
EDIT: adding picture here
Dear All,
I am reading data into my MATLAB code throguh several .xls files; occassionally, I am running into the error, 'Error using xlsread'. Could someone please help me understand the source of this error and help fix it.
Thanks in advnace!
Regards,
  5 Comments
dpb
dpb on 1 Nov 2023
Well, that's a painful way for respondents/volunteers here to have to try to search out what went wrong, @Kareemulla Dudekula. At a barest of minimums attach the text of the error (all the red text) in context with the code you ran that generated the error.
It's likely no real solution will be possible without the actual spreadsheet to test with; attach it instead of the one you did.
Then, @KSSV's comment is extremely pertinent, don't use deprecated xlsread but one of the modern suggested replacements; readtable would be another likely candidate.
Kareemulla Dudekula
Kareemulla Dudekula on 4 Nov 2023
Thank you very much for the suggestions; I shall implement and see if the this persistan problem can be fixed.
Regards,

Sign in to comment.

Answers (1)

Yash
Yash on 2 Jan 2024
Hi Kareemulla,
I understand you are facing issues while using the "xlsread" function. As per the MATLAB documentation, "xlsread" is deprecated and is not recommended. You should use "readtable", "readmatrix", or "readcell" instead.
If, due to some reasons, you need to use "xlsread" function only, then consider the following points:
The error that you are facing is caused by excel, whis might be due to a variety of reasons. It is not possible to determine the exact reason without the actual spreadsheet. You can try these troubleshooting steps:
  • Restart MATLAB: This works in most of the cases. The problem often resolves after a fresh restart.
  • Check File Name Length: The character limit on the length of a filename in Excel (folder + base file name) is limited to 218 characters. ensure that it is shorter than that.
  • Protected Mode in Excel: If the file is opened in the protected mode, make sure you enable editing and disable the protected mode.
  • Network directory: If the file is present in a network(shared) folder, there might be a chance that many users are accessing the same file simultaneously. Try to copy that on your local disk and run again.
You can also seek help from the following MATLAB Answer:
I hope these suggestions help you address your query.

Tags

Community Treasure Hunt

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

Start Hunting!