MATLAB 2024a readtable error

Error Message:
This is a similar error as discussed here for MATLAB 2018b.
I have a script using readtable('data.csv') running on MATLAB 2024a that is producing this error if I modify my path from the MATLAB default (set by restoredefaultpath):
Error using readtable (line 517)
inputs must be a string array, character vector, or cell array of character vectors.
Trouble Shooting I've Tried:
If I run restoredefaultpath and then execute T = readtable('data.csv') it runs OK.
T = readtable('data.csv')
T = 14x3 table
x y z ______ ______ _____ 51.403 1.6335 -17.7 51.435 1.5943 -19.2 51.376 1.5914 -16.3 51.444 1.647 -22 51.438 1.6169 -21.3 51.395 1.6387 -17.8 51.399 1.6371 -16.7 51.357 1.6112 -22.1 51.363 1.6218 -21.1 51.386 1.5912 -14.4 51.437 1.6167 -21.2 51.401 1.6049 -16.6 51.447 1.6257 -21.9 51.382 1.611 -14.6
It seems like MATLAB can find readtable.m but cannot find readData.m:
which readTable -all` returns C:\Program Files\MATLAB\R2024a\toolbox\matlab\iofun\readtable.m
and
which readData -all returns 'readdata' not found
both with the default path and my modified path.
I've tried uninstalling and then reinstalling MATLAB 2024a to no sucess.
Requested Help:
However, I need to be able to modify my path so that my script can access the m-files it needs. What can I do to fix this problem? Thank you for your help!

4 comentarios

Walter Roberson
Walter Roberson el 21 de Ag. de 2024
It sounds as if something in the modified path is clashing with an internal routine needed by readtable()
You will need to use the debugger "step in" function to trace down the problem.
Put a breakpoint in matlab.io.internal.functions/ReadTable/execute and start stepping.
Samuel
Samuel el 21 de Ag. de 2024
@Walter Roberson I used the "step in" function with a break at your suggested location, and the MATLAB function worked OK up undtil it reached the private method getOptsFromDetection of DetectImportOptionsText.m located in the default location
C:\Program Files\MATLAB\R2024a\toolbox\matlab\io\text\+matlab\+io\+internal\+functions\DetectImportOptionsText.m.
An error was thrown on line 111 the method getOptsFromDetection(func,supplied). The screen shots below show where the error is occuring. It looks like the LineEnding property is not set correctly?
I am not sure how to trouble shoot futher or ID how something that I added to my path produce this error.
Walter Roberson
Walter Roberson el 21 de Ag. de 2024
That's odd, since clearly the inputs are a cell array of character vectors. The problem must be inside the unescape function.
Good work in tracing it down this far!
Samuel
Samuel el 22 de Ag. de 2024
Editada: Samuel el 22 de Ag. de 2024
The fix I needed is now noted in the 'Accepted Answer'. It is not clear to me why it was this function that was throwing the error; removing the replace.m function in my path that was shadowing the MATLAB function of the same name made MATLAB's readtable.m function work as itendend.
Thank you for your direction in debugging!

Iniciar sesión para comentar.

 Respuesta aceptada

Steven Lord
Steven Lord el 21 de Ag. de 2024
Please attempt to reproduce this failure on your machine. If you can, immediately (before running any other command that could throw an error) run the following line of code at the MATLAB Command Prompt (the >>) and show what it displays (and if you could save the variable ME and attach the MAT-file containing it to the post that would be useful too.)
ME = MException.last
The identifier property may help indicate what function caused that error.
My suspicion is that you've written your own string processing function (strcmpi perhaps) or downloaded one that shadows a function built into MATLAB or that ships with it. The lower-case I starting the error message is a bit of evidence that supports that suspicion.

5 comentarios

Samuel
Samuel el 21 de Ag. de 2024
@Steven Lord here is a screen shot of running ME = MException.last right after readtable produces the error.
The workspace .mat file is also attached. The data in raw_file is not -- though the data.csv in the oringal post is a subset of the simple xyz data I am trying to read.
I will review my own code that may be producing an error message like this. Initial checks didn't flag anything, however.
Samuel
Samuel el 21 de Ag. de 2024
@Steven Lord I did some more manual debugging and found the folder that was producing this error.
Since this is not a MATLAB issue and general, and more of one of how I have configured MATLAB to run on my machine, I am requesting no further debugging help. Some more detective work will hopefully ID what .m file is producing the error ... but for now I can just leave out this folder from my path.
Thank you @Star Strider and @Walter Roberson and @Steven Lord for your help, I appreciate it!
I think I see where that message would have been thrown from. Can you check if you have a replace function that's not the one included with MATLAB?
which -all replace
/MATLAB/toolbox/matlab/strfun/replace.m replace is a built-in method % string method replace is a Java method % java.lang.String method /MATLAB/toolbox/matlab/testframework/unittest/core/+matlab/+unittest/+plugins/+plugindata/ResultDetails.m % matlab.unittest.plugins.plugindata.ResultDetails method replace is a Java method % java.util.HashMap method replace is a Java method % java.util.AbstractMap method replace is a Java method % java.util.Map method replace is a Java method % java.util.Collections$UnmodifiableMap method /MATLAB/toolbox/matlab/bigdata/@tall/replace.m % tall method /MATLAB/toolbox/parallel/array/distributed/@codistributed/replace.m % codistributed method
Samuel
Samuel el 21 de Ag. de 2024
@Steven Lord the call
which -all replace
returns
C:\Users\SamuelRickerich\Desktop\code\tools\tools_COAWST\m-cmg\omviz\replace.m
C:\Program Files\MATLAB\R2024a\toolbox\matlab\strfun\replace.m % Shadowed
replace is a built-in method % string method
replace is a Java method % java.lang.String method
C:\Program Files\MATLAB\R2024a\toolbox\matlab\bigdata\@tall\replace.m % tall method
The replace.m function that is shadowing the defaults is now renamed and I have no problems. This is a good lesson learned for me; thank you.
Steven Lord
Steven Lord el 21 de Ag. de 2024
Glad we were able to track down the root cause of that error!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2024a

Etiquetas

Preguntada:

el 21 de Ag. de 2024

Editada:

el 22 de Ag. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by