Tuesday, 28 June 2016

Undefined function 'readtable' for input arguments of type 'char'. or type 'double'.

There are two separate errors for the readtable() function in MATLAB that can occur for different reasons. The first is the following:

Undefined function 'readtable' for input arguments of type 'char'.

This occurs when passing a filename to the 'readtable()' function, as it expects to be passed a file hander, so instead the following usage should be used:

fid = fopen(file, 'r');
T = readtable(fid, 'Delimiter', ',', 'Format', format_spec);
flcose(fid);

The other reason for getting this error is using a version of MATLAB that is too old. If you run the code with this change, with a version of MATLAB that is too old then you will get the following error:

Undefined function 'readtable' for input arguments of type 'double'.

The readtable() function was introduced to MATLAB in R2013b, so any versions earlier than this will give this error as the function is not defined.

No comments:

Post a Comment