MATLAB Answers


Basic functions not working

Asked by CR
on 3 Apr 2017
Latest activity Commented on by Walter Roberson
on 4 Apr 2017
Over the past week or so I've been having a Matlab-wide problem where basic functions have stopped working. Trying to use a code suite(designed for EEG analysis using the EEGLAB plug-in) that had previously worked very smoothly, now results in a number of errors depending on what I'm trying to do with it. The first problem I got was that mkdir was unable to create a cache folder in a directory where permissions would not be an issue. Subsequently trying to use xlsread has given numerous errors, for instance:
Error using xlsread (line 260)
Undefined function 'find' for input arguments of type 'function_handle'.
I've tried reorganizing my paths as well as reverting to the default path set with no avail. Testing xlsread outside of the context of our code leads to errors along the lines of 'Undefined variable "[filename]" or class "[filename].xlsx".' in various situations.
I attempted to update from 2015b to 2017a, but the issue persists. I haven't been able to find anything in the answers where there was an issue that was so general and impacted some of the more basic functionality of the program, but if you suspect this has already been dealt with please point me in the proper direction, otherwise any thoughts on what might cause/fix this are greatly appreciated!


I would suggest using
dbstop if caught error
dbstop('in', which('xlsreadXLSX.m'))
and then
and then use the debugger to advance through the code.
Does the error occur at
sheetIndex = find(strcmp(sheetNames,sheetName));
or does it occur in one of the strfind() calls?
on 4 Apr 2017
Thanks for the debugging help. The first time I tried it using a recently used line of code that looked for the raw data and the error came when xlsread tried to use the find function within 'ismatch3.m' (Line 141, 'x = find(...)') or something along those lines.
I restarted the program to see if that might have an effect, and xlsread started working for both the num and raw output types, however adding some necessary folders to my path(mostly containing EEGLAB) broke it again. EEGLAB doesn't appear to have a find.m that would get in the way and our code definitely doesn't. Even moving the new locations to the bottom of the path doesn't fix the situation, it only works with the default path set.
So now I suspect the issue is with the paths, but I'm not sure what exactly is causing it. Initially trying to figure this out I had been running into errors with different project path-sets so it seems to be more general than just an issue with EEGLAB scripts or something like that. Previously, I've also had somewhat regular problems saving the path file(usually fixed by restarting), and perhaps that's related.
ismatch3.m is not a Mathworks provided routine ?

Sign in to comment.

1 Answer

Answer by Spencer Chen on 4 Apr 2017

It looks to me that somehow the internal "find" function is overridden with another function in the Matlab path or by a variable name. You can use:
> which find
to check that out.
If that's the case, rename your custom function or variable.
For custom code, I recommend using Matlab's package (+folder) file organization to avoid confusion with built-in functions and functions from other downloaded toolboxes. E.g. put a custom "find" function as "+my\find.m", and execute the custom find function using:
> my.find(...)


Sign in to comment.