'Out of memory. The likely cause is an infinite recursion within the program.

167 次查看(过去 30 天)
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?
  7 个评论
Steven Lord
Steven Lord 2019-6-12
It could be a fileparts.m, but the fileparts function included in MATLAB does call isrow as part of its execution.

请先登录,再进行评论。

采纳的回答

Steven Lord
Steven Lord 2019-6-12
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.
  1 个评论
Magdalena Kachlicka
Thank you all for your help! I really appreciate it!
There is indeed a function called "inrow.m" in the FieldTrip toolbox folder! I was looking for a problem in Matlab and my own scripts, and it didn't make much sense, but it didn't cross my mind to check the very contents of the downloaded toolboxes I'm using.
This very much explains why the problem was coming back after cleaning cache and adding those folders back to the path. Something must have happened with my folders settings - my default path for FieldTrip should only include selected folders, not all of them, so when I deselected those I'm not using (incl. the one containing this function!), the problem was solved!
Once again big thanks!

请先登录,再进行评论。

更多回答(4 个)

Arhant Jain
Arhant Jain 2020-8-29
Inside the eeglab lab folder, just delete the folder associated with fieldtrip box. It will solve your problem.

Deepak Khani
Deepak Khani 2020-10-26
Out of memory. The likely cause is an infinite recursion
within the program.
Error in vdp1 (line 3)
[t,y] = ode45(@vdp1,[0 20],[2; 0]);
  5 个评论
Walter Roberson
Walter Roberson 2020-10-27
%calls to the function go **before** the function definition
[t,y]=ode45(@vds1,[0 20],[2; 0]);
plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of viscous damping force with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
%my1''+cy1'+ky1=0 is the equation of viscous damping Single degree of freedom.
%Rewrite this equation as a system of first order ODEs by making the
%substitution y1'=y2 and m=20kg ,c=10, k=30;
function dydt = vds1(t,y)
c=10;
k=20;
m=20;
dydt=[y(2);-(c*y(2)+k*y(1))/m];
end
This can all go in one file instead of splitting into two files, but if you put it in one file, then the one file cannot be named vds1.m

请先登录,再进行评论。


Brianna Biondo
Brianna Biondo 2021-7-26
Out of memory. The likely cause is an infinite recursion
within the program.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); %ODE15I sets args{1} to yp0.
  2 个评论
Brianna Biondo
Brianna Biondo 2021-7-26
function dNcelldt = intcellstorednitrogen (~, Ncell)
muMax = 0.26;
KN = 0.033;
KS = 0.077;
KiS = 500;
KiX = 152;
YXN = 27;
KiN = 0.073;
N0 = [5;0];
tRange = (0:144);
[~,NSol] = ode45(@nitrogenconsumption,tRange, N0 );
S0 = [100;0];
[~,SSol] = ode45(@glucoseconsumption,tRange, S0 );
Xf0 = [0.2;0];
[~,XfSol] = ode45(@lipidfreecellgrowth,tRange, Xf0 );
for N = 1:numel(NSol); S = 1:numel(SSol) ; Xf = 1:numel(XfSol);
muS = muMax .* (N/(KN +N)) .* (S/(KS+S)) .* (1/(1+(S/KiS))) .* (1/(1+(Xf/KiX)));
muN = muMax .*(1./(1+(N/KiN))) .* (Ncell./((1/(10.*YXN))+Ncell)) .* (S./(KS+S)) .* (1./(1+(S/KS))).* (1./(1+(Xf./KiS)));
dNcelldt = (-(((1/(3.*YXN))-Ncell).*muS)+(((2/(3.*YXN))+Ncell).*muN))*t;
end
end
Steven Lord
Steven Lord 2021-7-26
You call the ode45 function three times in this code. One of those calls (with nitrogenconsumption, glucoseconsumption, or lipidfreecellgrowth as the ODE functions) will eventually have them call ode45 with that function as the ODE function.
So for example if nitrogenconsumption includes a line that says
[~, Nsol] = ode45(@nitrogenconsumption, % some other code
then nitrogenconsumption would call ode45 which would call nitrogenconsumption which would call ode45 which would call nitrogenconsumption which would call ode45 which would call nitrogenconsumption which would call ode45 ... and eventually MATLAB throws this error.
Move the ode45 call outside the function that it will call (that you've specified as the first input argument.)

请先登录,再进行评论。


Hailat Berhane Ghebremdhin
Hej I am trying to generate graphys for the following equations
f= @(x) 1-sin(x);
fixpointgraf(f,0,pi,-1,1)
testpoints = linspace(.45,.55)
punktStabil(f,testpoints)
fixIter(f,.5,100)
by using the following graph. But I still get " Out of memory. The likely cause is an infinite recursion within the program. Error in newPlot(line 53) fig = goobjects(0);
function fixpointgraf(f,a,b,c,d)
x= linspace(a,b);
plot(x,f(x))
hold on
plot(x,x )
fixpointgraf(f,a,b,c,d)
end
function stabil = punktStabil(f,testpoints)
h=1e-7;
Delta=(f(testpoints+(h))-f(testpoints))/(h);
stabil= false;
for i=1:1:length(Delta)-1
if abs(Delta(i))>1
stabil= true;
end
end
if punktStabil(f,Delta)
disp('punkten nära 1.6 är stabil för f')
else
disp('punkten nära 1.6 äe ej stabil för f1.')
end
end
function iter_lst = fixIter(f,x0,N)
iter_lst = zeros(N,1); % skapa en lista med 100 nollor vi kan fylla.
iter_lst(1) = x0;
for k=1:1:N
iter_lst(1i ) = f(iter_lst(1i-1));
end
figure()
scatter(1:1:N,iter_lst)
end
here is my code without the function
f=@(x) x/2 -1
x = linspace(-4,10);
plot(x,f(x))
hold on plot(x,x)
axis([-4,4,-4,4])
testpoints = linspace(0.45,0.55);
h=1e-7;
Delta = (f(x+h)-f(x))/h;
found = false;
for i=1:1:length(Delta)-1
if abs(Delta(i))>1
found = true;
end
end
iter_lst= zeros(100,1);
iter_lst(1)=-2;
for k= 1:1:100
iter_lst(k)=f(iter_lst(k-1));
end figure()
scatter(1:1:100,iter_lst)
  2 个评论
Jan
Jan 2023-1-29
  • Please do not post a new question in the sections for answers of another question. Open a new thread instead. Then delete the message here. Thanks.
  • Please use the toolbar above the field for entering messages to format the code. This improves the readability.
  • Please du not bump your question by appending a comment, which does not contain new information. This does not increase your chance to get an answer, but wastes times of the readers only. The reason for missing answers is not, that the members have not been pushed enough, but that the questions do not contain enough information.
  • Avoid terms like "immediate" or "as soon as possible", because they reduce the motivation to post an answer. Remember that all questions are urgent for the asking persons.
Walter Roberson
Walter Roberson 2023-1-29
you have
function fixpointgraf(f,a,b,c,d)
x= linspace(a,b);
plot(x,f(x))
hold on
plot(x,x )
fixpointgraf(f,a,b,c,d)
end
so the function fixedpointgraf starts executing. It does some operations to calculate and plot something, and then it calls a function to do the remaining work. The function that is called is fixedpointgraf and it is called with exactly the same parameters. So it starts executing, computes and graphs the same thing as last time, then calls function fixedpointgraf to finish the work... which is exactly the same function. Function fixedpointgraf cannot return until all functions called inside it return, but it is calling itself with the same parameters...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by