Hey ,
I have the following nonlinear system.
And I'd like to approximate the solution via the midpoint rule , that is
I choose the stepsize h=0.01. x_{n+1} denotes the solution at time t=h(n+1).
I did the following:
fun=@root2d;x0=[20,20];sol=fsolve(@(x)root2d(x,20,20),x0) function F=root2d(x,xold,yold)F(1)=x(1)-xold-dt*((1/2)*(x(1)+xold)-A*(1/2)*(x(1)+xold)*(x(2)+yold));F(2)=x(2)-yold-dt*(-(1/2)*(x(2)+yold)+B*(1/2)*(x(1)+xold)*(x(2)+yold));end
but I keep getting the error code
Caused by: Failure in initial objective function evaluation. FSOLVE cannot continue.
Actually , I was quite confused anyway when I tried to implement it since I was not sure how to deal with the initial values and it seems like i incoorporated them twice..I hope somebody can help me !
Thanks.
Best Answer