Parameter Scan (Non-Linear system)

14 Ansichten (letzte 30 Tage)
Joseph Hughes
Joseph Hughes am 23 Mär. 2011
So my coursework for university involves a predator prey model:
?x = ax(1-x) - xy - p(1 - exp(-qx))
?y = -y + bxy(-y/c)
We are given the variables a, b, c and q (q is generated by an unseen m-file called GeneratePar, this makes everybody's coursework individual)
The first task we were given was to write a function that would find the Jacobian of any matrix(called MyJacobian.m).... I have done this successfully.
The second task was to use newton iteration to write a function (called MySolve.m) that incorporated MyJacobain, the task involved writing a function that would solve a non linear system of equations of the form f(x)=0...... I have done this successfully (with the help of some people here)
so the task I am now stuck with is writing a function called ParameterScan.m:
The aim of this function is to find the equilibria of the predator prey system. the equilibria exist only in a range of parameters p from 0 to p(max). we are told to use a for-loop for parameter p which calls MySolve for each value of p and use the solution for the previous parameter p as the initial guess. then to plot the results in the (p, x) plane and the (p, y) plane
Here is the code i have so far which obviously is not working,what i have written so far is based upon some examples we have been shown.
x y=@(x,a,b,c,p,q)...
[((a*x(1))*(1-x(1)))-(x(1)*x(2))-(p*(1-(exp(-q*x(1)))));...
-x(2)+((b*x(1)*x(2))*(exp(-x(2)/c)))];
a=5;
b=5;
c=5;
q=GeneratePar(414378);
pvec=0:5e-3:0.2;
x0=[0,0];
na=length(pvec);
xvec=zeros(length(x0),na);
for i=1:na
f=@(x)xy(x,a,b,c,pvec(i),q);
[x,converged]=MySolve(f,x0,1e-10,10);
if converged>0
xvec(:,i)=x;
x0=x;
fprintf('i=%d, a=%g, |x|=%g\n',i,pvec(i),norm(x));
else
fprintf('i=%d, a=%g, no convergence\n',i,pvec(i));
xvec(:,i)=NaN;
end
end
plot(pvec,xvec,'.');
grid on
I am aware that this may seem like i am asking someone to 'do' my coursework for me, i am not i'm just trying to get some tips as i am now stuck :(
  1 Kommentar
Walter Roberson
Walter Roberson am 12 Apr. 2011
Sorry, what do the ? represent in the model ?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Modeling finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by