⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex10ch4.m

📁 these codes are for solving OED with matlab
💻 M
字号:
function sol = ex10ch4history = [80; 30];tspan = [0, 100];opts = ddeset('RelTol',1e-5,'AbsTol',1e-8);% Solve the ODEs that arise when there is no delay.sol0 = dde23(@ddes,[],history,tspan,opts);% Solve the DDEs that arise when there is a delay of tau.tau = 1;sol1 = dde23(@ddes,tau,history,tspan,opts);plot(sol0.y(1,:),sol0.y(2,:),sol1.y(1,:),sol1.y(2,:))title('Predator--Prey Solution With and Without Delay')xlabel('y_1(t)')ylabel('y_2(t)')legend('No delay',['Delay \tau = ',num2str(tau)],2)%=======================================================function v = ddes(t,y,Z)a = 0.25;b = -0.01;c = -1.00;d =  0.01;v = zeros(2,1);if isempty(Z)     % ODEs   v(1) = a * y(1) + b * y(1) * y(2);   v(2) = c * y(2) + d * y(1) * y(2);else              % DDEs   m = 200;   ylag = Z(:,1);   v(1) = a * y(1) * (1 - y(1) / m) + b * y(1)    * y(2);   v(2) = c * y(2)                  + d * ylag(1) * ylag(2);end

⌨️ 快捷键说明

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