Numerically Solving Systems of Ordinary Differential Equations (1st order ODEs)
Systems of ODEs solving by MATLAB
Ordinary differential equations, or ODEs, play a significant role in different applications. And often, the numerical techniques are best to approach to solve them. Let’s see how we do this in MATLAB by solving first-order systems of ordinary differential equations. Here we concerned about the application of the spread of HIV infection.
Equations
The equations are momentary balances based on the amount of healthy cells (H), infected cells (I), and viral count (V). In this equation system, Terms with a positive sign increase the equivalent quantity of cells or virus. Similarly, phrases with a minus sign reduce the number of cells or viruses.

The model contains six parameters kr1,kr2,kr3,kr4,kr5 and kr6, that provide cell death rates, infection dissemination, virus replication, and other processes that influence HIV spread in the body.
Parameters Values
As above mentioned, there are six parameters with their correspondings values.
Simulation by MATLAB
I hope you all know that we can obtain a solution to a single differential equation by using MATLAB. Then let’s see how we do this with the ode45 function in MATLAB solving a system of ODEs. As previously stated, the ode45 function is the most often used ODE solver in MATLAB.
To do this, first, we have to convert the system of ODEs into a new format. Therefore, the first step is to combine all of these ODEs into a single equation for a single variable that we will call X.

The strategy is to create X, a column vector with three components, each corresponding to one of the variables H, I, and V. Then, we take the derivative of each element of X. The corresponding equation determines each value from the original system.
Now that we have a vectorized system of ODEs, the next step is to construct a MATLAB function. This function computes the derivative vector value for use with the ode45 function. Our ‘model’ function will generate a single output dXdt for given input values t and X.
The final step is to invoke the ode45 function by passing a handle to our derivative function, a vector containing the initial and final time values. In here initial conditions are H_0 = 1000000, I_0 = 0 and V_0 = 100.
Conclusion
The solution to our differential equation is recorded in the output variables ‘Xsol’ and ‘tsol’ when we run this script. The first output is a vector containing the time values used to compute the numerical solution. The second output is a matrix containing the calculated value of variable X for each time in ‘tsol’. Individual columns can then be extracted for additional analysis or visualisation.
References
Nowak, M. and May, R. M. Virus dynamics: mathematical principles of immunology and virology: mathematical principles of immunology and virology. Oxford university press, 2000.