I'm looking for getting the matlab codes for soving nonlinear differential equations? These equations are from a research paper on HIV AIDS.
2 views (last 30 days)
Show older comments
These equations are from Mathematical Modelling of HIV AIDS Dynamics with Treatment and Vertical Transmission.
0 Comments
Accepted Answer
Are Mjaavatten
on 20 Dec 2017
Edited: Are Mjaavatten
on 20 Dec 2017
Matlab has several functions for integrating systems of differential equation. Type
doc ode45
for more information.
In your case, start by creating a Matlab function that calculates the right-hand side of your equations. Here is a skeleton to get you started:
function dzdt = rhs(t,z,par)
% Right-hand side of differential equations
% par: Parameter struct
% Unpack vector of dependent variables:
S = z(1);
I = z(2);
P = z(3);
T = z(4);
A = z(5);
dSdt = pi*par.N - (par.c(1)*par.beta(1)*I + par.c(2)*par.beta(2)*P)...
*S/par.N - % ... and so on
% In the same way for the remaining equation
dzdt = [dSdt;dIdt;dPdt;dTdt;dAdt];
end
Next, write a Matlab script where you:
1) Define parameters
par.N = 200;
par.c = [2.3,-127.4];
2) Specify initial conditions:
S0 = 0; I0 = 2.4; % ... and so on
z0 = [S0;I0;P0;T0;A0];
3) Specify integration interval and call the solver:
tmax = 1; % Start with a low end time for debugging purposes
[t,z] = ode45(fun,[0,tmax],z0); % You may have to try alternative solvers
4) If all goes well you may plot results:
S = z(:,1);
I = z(:,2);
plot(t,S,t,I);
0 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!