From: Husam Aldahiyat on
"Vyjayanthi A" <vinzav(a)gmail.com> wrote in message <hn33uk$bnt$1(a)fred.mathworks.com>...
> "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hn2r1k$c8s$1(a)fred.mathworks.com>...
> > Dear Vyjayanthi!
> >
> > > I am trying to solve nonlinear implicit functions using fminsearch.
> > > When I execute the program I get an error of:
> > > ??? Maximum recursion limit of 1 reached. Use set(0,'RecursionLimit',N)
> > > to change the limit. Be aware that exceeding your available stack space can
> > > crash MATLAB and/or your computer.
> > > How should I minimize the above error.
> >
> > Please read the error message again. It tells you, that any function is called recursively again and again. Most likely this is a programming error. You can clear this by inspecting in the line, which number is shown together with the error message.
> >
> > Good luck, Jan
>
> Hi Jan Simon,
> I tried doing that, but I couldn't figure out where the exact error is taking place.
> It says to set(0,'RecursionLimit',N).
> even after I set this I get the same error message, I have been trying from past one week to solve this.Please help me out with this program.
>
>
>
>
>
> %function b = nonlinear2(v,x1,x2,x3,x4,x5,x6)
> function b = nonlinear4(v) %,x1,x2,x3,x4,x5,x6)
>
> v=[1 1 1 -1 -1 1];
>
> %x1=v(1);% x2=v(2); % x3=v(3); % x4=v(4); % x5=v(5);% x6=v(6); %stress ui ffic E phi rhofic
>
> N=1;
>
> %options=optimset('maxfunevals',1,'MaxIter',1,'TolFun',1,'TolX',1,'OutputFcn',1,'LargeScale', 'off');
> %z=set(nonlinear4,'RecursionLimit',1);
> %val = optimget(options,'v',1);
> options=[];
> a=2*0.645*10^-3;
> y=2*2.34*10^-3;
> rhog=8.3;
> rhoc=626;
> visc=170*10^-6;
> Mg=1.67;
> fr=1*10^-3;
> ifg=2230*10^3;
> Q= 1.93*10^4;
> ug=0.189;
> f1=0.1932;
> g=9.8;
> deltaht=2.4*10^-2;
> x2=500;
> dh=0.0038;
>
> delta=((3*visc*Mg)/(rhoc*(rhoc-rhog)*g))^0.333;
> c1=(1-2*(delta/a))/(1-(delta/a));
> c2=(delta/a)/(1-(delta/a));
> c3=1/(1-delta/y)*(1-delta/a);
>
> b(1)=v(1)-(v(3)*rhog*(ug-v(2)).^2)/2;
> b(2)=v(2)-((rhoc-v(6))*delta^2*g)/(2*visc)+(v(1)*delta)/visc;
> b(3)=v(3)-(f1*v(4)+fr);
> b(4)=v(4)-abs((v(5))/(exp(v(5))-1));
> b(5)=v(5)-((2*Q)/(ifg*f1*rhog*(ug-v(2))));
> b(6)=v(6)-(rhog*(c1+c2*(rhoc/rhog)-((c3*x2)/(deltaht*rhog*g))-((4*v(1))/(rhog*g*dh))));
>
> [b, fval] = fminsearch(@nonlinear4,v,options) %,x1,x2,x3,x4,x5,x6)
>
>

The problem is that you are calling the function nonlinear4 inside the function nonlinear4. Then inside nonlinear4, nonlinear4 is called again, and then we call it inside the next iteration of nonlinear4, etc.

Put the final line in a different function, or simply type it in the main menu.
 | 
Pages: 1
Prev: Recursion limit
Next: Recursion limit