Problem with readtable MATLAB R2020a+

조회 수: 58(최근 30일)
Paolo Oliveri
Paolo Oliveri 2021년 7월 15일
편집: Paolo Oliveri 2021년 7월 19일
I am trying to read a basilar table in MATLAB.
I wrote some scripts and I had no problem until version 2020a, where I see that there are huge changes in tables management functions.
Here are the call to readtable that I always use:
readtable(devices_file, 'Delimiter', ',', 'Format','%q%q')
Starting from R2020a, the readtable fails with this strange error:
Error using readtable (line 318)
Undefined function 'isnan' for input arguments of type 'string'.
Note: readtable detected the following parameters:
'HeaderLines', , 'ReadVariableNames', true
Also readtable with no arguments fails. I inspected into the core and the fail seems to go deep and it is correlated to DelimitedTextImportOptions or some other similar function.
Using detectImprtOptions the error is similar:
detectImportOptions(devices_file, 'Delimiter', ',', 'Format','%q%q')
also here its the same omitting the arguments.
Check for incorrect argument data type or missing argument in call to function 'isnan'.
Error in detectImportOptions (line 381)
Do you know how to workaround this issue or if it is a bug that has to be resolved?
Paolo Oliveri
  댓글 수: 6
Paolo Oliveri
Paolo Oliveri 2021년 7월 16일
Ok, so maybe the problem is related to Linux releases only. Can anyone that runs MATLAB on Linux or MATLAB staff try to reproduce the problem?

댓글을 달려면 로그인하십시오.

채택된 답변

Jeremy Hughes
Jeremy Hughes 2021년 7월 17일
My best guess is that there's something installed on the path that conflicts with a function//variable that readtable is using internally. I am basing that on the fact that this doesn't seem to be happening with every user.
One way to test this, is to make sure you're using only the default path:
A more precise way is to set:
>> dbstop if caught error
Then run the command, using dbcont until you hit the line that's issuing the error "Undefined function 'isnan' for input arguments of type 'string'."
Then, on that line, look at all the names of all the functions/variables and call
>> which -all <each-thing-on-that-line>
If you see something "shadowed" that's likely the problem.
You can also try technical support.
  댓글 수: 1
Paolo Oliveri
Paolo Oliveri 2021년 7월 19일
편집: Paolo Oliveri 2021년 7월 19일
thank you for your answer! In fact there was a previous release of
function in my path (I did not know that there were) that interfered with the readtable routines. I removed it and all turned working.
Thank you!
Paolo Oliveri

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Christopher McCausland
Christopher McCausland 2021년 7월 15일
Hi Paolo,
I am hoping I have an answer for you however I am working in MATLAB 2020b, it is post 2020a so I think the changes should match up.
I believe the error message:
Undefined function 'isnan' for input arguments of type 'string'.
is generated as MATLAB is looking for the first input (i.e. the file name) in the readtable function to be a string, try changing to this;
readtable('devices_file.csv', 'Delimiter', ',', 'Format','%q%q') // note the added '' and .csv in the first input
this should hopefully prevent the isnan error, lastly double check the file name as the attached file was called "devices" and not "devices_file"
Let me know if this helps!
  댓글 수: 1
Paolo Oliveri
Paolo Oliveri 2021년 7월 15일
thank you for your answer.
I did not paste the code completely, only the readtable line. There are other lines of code where I define de variable "devices_file". So this is not the problem.
Please also remember that I am using also MATLAB R2019b and all of my script work without any problem.

댓글을 달려면 로그인하십시오.


Find more on Data Import from MATLAB 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!

Translated by