MATLAB 2024a readtable error

24 vues (au cours des 30 derniers jours)
Samuel
Samuel le 21 Août 2024
Modifié(e) : Samuel le 22 Août 2024
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 commentaires
Walter Roberson
Walter Roberson le 21 Août 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 le 22 Août 2024
Modifié(e) : Samuel le 22 Août 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!

Connectez-vous pour commenter.

Réponse acceptée

Steven Lord
Steven Lord le 21 Août 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 commentaires
Samuel
Samuel le 21 Août 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 le 21 Août 2024
Glad we were able to track down the root cause of that error!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by