MATLAB: ‘Out of memory. The likely cause is an infinite recursion within the program.

infinite recursion errormultiple functions error

Hi all,
I've seen many people reporting the appearance of this error in relation to some functions, and there are many responses on how to fix those functions to avoid infinite recursion. However, in my case, I get this error when I'm trying to use any functions (even those which has been working properly before) and even when trying to open a script or a figure (!). I can't even load the data.
Any idea how I can fix this?

Best Answer

Guillaume is correct. You've written your own isrow.m that shadows the built-in isrow function.
The fileparts function that is part of MATLAB calls isrow as part of its execution. The isrow function that is part of MATLAB (and which fileparts normally calls) is a built-in function, but the error message shows that the error occurs on line 11 of isrow.m which calls fileparts. Calling fileparts calls isrow which calls fileparts which calls isrow .... Many functions (including open) call fileparts and so enter this infinite loop.
Rename or remove the isrow.m file. You may also want to check (using which) if you've shadowed additional built-in functions in the same directory and rename or remove them as well.