predprey2.m

来自「ode routines in matlab」· M 代码 · 共 35 行

M
35
字号
function [out] = PredPrey2(x, y,flag)%%  Evaluate the right hand side function for the%  Predator Prey model%%                                         y_1(x) * y_2(x)%    y_1'(x) = 1.2 * y_1(x) - y_1^2(x) -  ---------------%                                          y_1(x) + 0.2%%               1.5 * y_1(x) * y_2(x)%    y_2'(x) =  ---------------------  -  y_2(x)%                   y_1(x) + 0.2%%%switch( flag )   case '' % return right hand side      out  = [ 1.2*y(1) - y(1)^2 - (y(1)*y(2)) / (y(1)+0.2);               (1.5*y(1)*y(2)) / (y(1)+0.2) - y(2) ];      case 'jacobian' % return Jaacobian of right hand side      out  = [ 1.2 - 2*y(1) - y(2)/(y(1)+0.2)^2   y(1) / (y(1)+0.2) ;               0.3*y(1)/(y(1)+0.2)^2              (1.5*y(1)) / (y(1)+0.2) - 1 ];      otherwise      error(['Unknown request.'])end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?