Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code for ODE solve % matlab code to solve ode system function solveodesys % This is a simple example that illustrates the

This is the code for ODE solve

% matlab code to solve ode system function solveodesys % This is a simple example that illustrates the % straightforward formulation, computation, and plotting of the solution % of a system of ordinary differential equations (ODEs). % % The differential equations % % y'_ 1(t) = a*y_ 1(t)-b*y_ 1(t)*y_ 2(t)-d1*y_ 1(t)+g*y_ 3(t) % y'_ 2(t) = b*y_ 1(t)*y_ 2(t)-(c+d2)*y_ 2(t) % y'_ 3(t) = c*y_ 2(t)-g*y_ 3(t)-d1*y_ 3(t) % % are solved on [0, Time] with initial condition y_ 1(t) = 1000, y_ 2(t) = 1, y_ 3(t) = 0 for % t = 0.

% Algorithms: % (1) ode45 is based on an explicit Runge-Kutta formula, the Dormand-Prince pair. It is a one-step solver- in computing y(tn), it needs only the solution at the immediately preceding time point, y (tn-1). % Ingeneral, ode45 is the best function to apply as a "first try" for most problems. % (2) ode23 is an implementation of an explicit Runge-Kutta pair of Bogacki and Shampine. It may bemore efficient than ode45 at crude tolerances and in the presence of moderate stiffness. % Like ode45,ode23 is a one-step solver. % (3) ode113 is a variable order Adams-Bashforth-Moulton PECE solver. It may be more efficient than ode45 at stringent tolerances and when the ODE file function is particularly expensive to evaluate. % ode113 is amultistep solver - it normally needs the solutions at several preceding time points to compute the currentsolution. The above algorithms are intended to solve non-stiff systems. % If they appear to be unduly slow, try usingone of the stiff solvers (ode15s and ode23s) instead. % (4) ode15s is a variable order solver based on the numerical differentiation formulas, NDFs. Optionally, ituses the backward differentiation formulas, BDFs (also known as Gear's method) that are usually % less efficient. Like ode113, ode15s is a multistep solver. If you suspect that a problem is stiff or if ode45 hasfailed or was very inefficient, try ode15s. % (5) ode23s is based on a modified Rosenbrock formula of order 2. Because it is a one-step solver, it may bemore efficient than ode15s at crude tolerances. It can solve some kinds of stiff problems for which % ode15s is not effective.

Time=200;

options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);% set error tolerance for the following numerical methods [t1,sol1] = ode45(@odefun,[0 Time],[1000 1 0],options); [t2,sol2] = ode23(@odefun,[0 Time],[1000 1 0],options); [t3,sol3] = ode113(@odefun,[0 Time],[1000 1 0],options); [t4,sol4] = ode15s(@odefun,[0 Time],[1000 1 0],options); [t5,sol5] = ode23s(@odefun,[0 Time],[1000 1 0],options);

T=cell(1,5); X=cell(1,5); Y=cell(1,5); Z=cell(1,5);

T{1}=t1;T{2}=t2;T{3}=t3;T{4}=t4;T{5}=t5; X{1}=sol1(:,1);X{2}=sol2(:,1);X{3}=sol3(:,1);X{4}=sol4(:,1);X{5}=sol5(:,1); Y{1}=sol1(:,2);Y{2}=sol2(:,2);Y{3}=sol3(:,2);Y{4}=sol4(:,2);Y{5}=sol5(:,2); Z{1}=sol1(:,3);Z{2}=sol2(:,3);Z{3}=sol3(:,3);Z{4}=sol4(:,3);Z{5}=sol5(:,3);

colorstring = 'kcgrb'; figure; subplot(1,3,1) hold on i=1; while i<6 plot(T{i},X{i}, 'Color', colorstring(i)); i=i+1; end xlabel('time t'); ylabel('y (1)'); subplot(1,3,2) hold on i=1; while i<6 plot(T{i},Y{i}, 'Color', colorstring(i)); i=i+1; end xlabel('time t'); ylabel('y (2)');

subplot(1,3,3) hold on i=1; while i<6 plot(T{i},Z{i}, 'Color', colorstring(i)); i=i+1; end xlabel('time t'); ylabel('y (3)'); legend('ode45','ode23','ode113','ode15s','ode23s');

function dy = odefun(t,y) a=0.4; b=0.01; c=0.2; d1=1/70; d2=1/70+0.1; g=0.15; dy=[ a*y(1)-b*y(1)*y(2)-d1*y(1)+g*y(3); b*y(1)*y(2)-(c+d2)*y(2); c*y(2)-g*y(3)-d1*y(3)];

Now we are trying to implment our equation into this code (this is what it looks like)

function dy = odefun(t,y) r1=1;K=3;aph1=0.59;aph2=0.3;aph3=0.3;bl=0.5; dl=0.4;c1=1/3;c2=1/25;c3=4/25;c4=1/4;c5=3/4; beta1 = 0.2;a=1/7;b1=1.5;d1=0.74;d2=0.74;beta2=0.45; dF/dt = r1*F*(1-F/K)- aph1*F*L - aph2*F*Jn - aph3*F*An; dL/dt = bl*L - dl*(L/(L+c4*F+Jn+1))*L - beta2*An*L; dJn/dt = b1*An - a*Jn - beta1*Jn*L - d1*(Jn/(Jn+c1*F+1))*Jn; dAn/dt = a*Jn - d2*(An/(An+c2*F+c3*L+1))*An];

there were some errors pop up when we were running this...

please help us to make it error free and able to run. (When its successfully done, there should be serveral plots comes out . Also are we able to figure out the equilibrium points from these functions?)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

Simplify the given expressions. 36 + 64

Answered: 1 week ago

Question

The number of units required for production is equal to

Answered: 1 week ago