MATLAB: Matlab doesn’t “Pause on Error” till Infinite recursion

pause on error

Hello,
for a project I am working on I have to rewrite a .m-file. As it is quite complex (at least for me) I move forward by running the edited script, getting the next error message, fixing the issue and reapeat. This worked fine for my last few projects, however with this, it's different.
When Matlab hits a line it can't execute (e.g. a function that is not in the file path), it throws an error (as expected)…
Undefined function or variable 'Output_data'.
Error in wPLI_openfield (line 237)
data.trial{k} = Output_data((j:(k*10000)),:)';
…but won't stop computing for a few minutes or so (haven't timed it yet, maybe 2 – 4 minutes?). After that I get the following error message:
Out of memory. The likely cause is an infinite recursion within the
program.
Error in fileparts (line 40)
elseif ~isrow(file)
The recursion unlikely comes from the script (had the same problem with different m.-files) i am editing. I guess it has to be a more basic problem of Matlab or its core functions. But honestly, I just don't know.
As this is quite annoying and I don't know where it comes from, I hope some of you guys can help me with this issue. I already tried reinstalling everything twice.
I'm using Matlab2018a 9.4 on my Windows 10 Home 64 bit system.

Best Answer

Try setting a breakpoint on line 237 of wPLI_openfield. When MATLAB reaches that point, it will enter debug mode and the prompt will change to K>>. At this point, check that the fileparts and isrow functions that are being called are the ones written by MathWorks.
which -all fileparts
which -all isrow
This will check if there are fileparts or isrow functions in a directory that wPLI_openfield (or something called before wPLI_openfield) changes to with cd or adds to the path with addpath (but that the code normally changes away from or removes from the path before returning to the Command Prompt) and so were not "visible" to MATLAB when you checked before.
If that doesn't show anything, Walter may still be correct that there is a third-party toolbox interfering. To check this, can you show the list of products displayed when you execute the ver function? That's not foolproof (not all third-party toolboxes do what's needed to show up in ver, but it might show something that we've seen before and recognize as a potential cause.