Passing parameters to ode 45 in MATLAB

546 Views Asked by At

I have to solve the ODE ,
enter image description here

where $f\epsilon$ is noise which is generated by random number.

My question is how can I pass the variables $\beta,\gamma,\mu,noise,N$ as inputs to ode45.

My code is

function [T,X,Y]=Stochastic_Solve(x0,y0,MaxTime,Step,noise,mu,beta,gamma,N)
    t=0;
    X=x0;Y=y0;T=[0];
    while(t<MaxTime & X>0 & Y>0)
        random_noise=randn(1);
        noise=noise*random_noise/sqrt(Step);  
        [tt,p]=ode45(@Equations,[t t+step],[X,Y],mu,beta,gamma,noise,N);

    end  

 function eqns=Equations(t,y,mu,beta,gamma,noise,N)
       eqns=zeros(2,1);
       eqns(1)=mu*N-((beta*y(1)*y(2)/N)+noise)-mu*y(1);
       eqns(2)=((beta*y(1)*y(2)/N)+noise)-gamma*y(2)-mu*y(2);

I get errors as

Error in observationalNoise>Equations (line 32)
       eqns(1)=mu*N-((beta*y(1)*y(2)/N)+noise)-mu*y(1);   


Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ode45 (line 115)
    odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);

Error in observationalNoise>Stochastic_Solve (line 25)
        [t,p]=ode45(@Equations,[t t+step],[X,Y],mu,beta,gamma,noise,N);  

So,when calling ode45 how can I give the parameters that are required to write the differential equations