Error using readtable: PATTERN must be a string scalar or character vector.

Hi all,
I used to read my .xlsx files using readtable without any error. I changed my computer and re-installed Matlab 2017a on windows 10 (was on the previous Windows before). Since then, each time I try to run a code like readtable('C:\myfile.xlsx'); , I have the following error : PATTERN must be a string scalar or character vector. I avoid this error if I do : readtable('C:\myfile.xlsx', 'ReadVariableNames', false). Any idea how to avoid the error and read the variable names at the same time ?
Thanks you!

1 Kommentar

Is there a traceback showing which line the error occurred on, and where it was called from?
My guess would be that you have your own (or a third-party toolbox) .m file on the MATLAB path that has the same name as something relied upon by MATLAB.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

You can use FEX: UniqueFuncNames to search for shadowed built-in functions.
Do not set user-defined folders on top of the path, but on the bottom, to avoid such bugs.
Posting the complete error message should reveal more details. And you can explore the crashing line by using the debugger:
dbstop if error
Now run the code again and examine, where the code fails.
Sofien Benouaghram
Sofien Benouaghram am 20 Okt. 2017
Thank you for your answers guys.
I checked with the "which function" and with UniqueFuncNames now and there is no second function with similar name. When I run the code with dbstop if error, the debugger stops on the error caller throwAsCaller(ME) where ME is the error I mentioned above.

2 Kommentare

Please provide the details. Weneed the complete message to know, where there error occurs. Explain what is found in the variable named PATTERN. Use the debssugger to find out, what's going on. We cannot do this for you, because it seems to happen on your system only.
Use
dbstop if caught error
and run. You might need to "dbcont" a couple of times to get past conditions that are normal.

Melden Sie sich an, um zu kommentieren.

Sofien Benouaghram
Sofien Benouaghram am 23 Okt. 2017
I finally found the error. Was a second function "contain.m" which was somehow saved in my MATLAB path. Thanks for your help on that guys!

Kategorien

Mehr zu Debugging and Analysis finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by