Solving a Simple Drug Delivery Model Using Analytical, Linear Algebra, and Numeric Approaches

Matthew Leineweber, San Jose State University, Biomedical Engineering
Author Profile
Initial Publication Date: August 23, 2019 | Reviewed: October 20, 2019


The delivery of orally ingested drugs, such as pills and capsules, can be roughly modeled as a system of first-order ordinary differential equations (ODEs). This type of "drug-delivery model" can be solved several different ways, including traditional analytical (e.g. "pencil-and-paper") methods, linear-algebra-based methods, and numerical approximation techniques. This activity details three techniques for using MATLAB to solve both homogeneous and non-homogeneous systems of linear differential equations.

Used this activity? Share your experiences and modifications

Learning Goals

- Students should recognize that there are often multiple approaches that can be used to solve a question
- Students will learn how a system of first-order differential equations can be treated as a system of linear equations
- Students will see how numerical solutions compare against
- MATLAB's symbolic toolbox is used to find and plot the analytical solution to the system
- MATLAB's built-in matrix solvers and Runge-Kutta algorithms are used to numerically approximate the behavior of the system, and then compare their results against the exact solutions produced by the other two methods.
- In addition to learning MATLAB syntax, students are asked to extrapolate the procedures introduced in the lab to explore how they can incorporate discontinuous input functions to the model and its solution

Context for Use

This activity was designed for use in a graduate (MS) level course "Mathematical Methods in Biomedical Engineering", attended by approximately 40 students. The students are mostly first year Master's students, with a handful of Seniors taking the course as a technical elective. There is no lab component to the course, so this activity is meant to be completed partially in-class and partially as a take-home homework assignment. Students should have at least an introductory knowledge of MATLAB programming to complete the script from the template provided to them. This lab has the students model a simplified drug-delivery process as a system of first-order ODEs. However, drug-delivery are only one example of systems of linear ODEs. The lab could easily be adapted to solving higher-order ODEs (e.g. mass-spring-damper systems in mechanical engineering), mixing problems for mathematics courses, etc.

Description and Teaching Materials

The activity is a guided walk through of the problem setup and solution approaches for a three-compartment drug-delivery model. The MATLAB Live Script includes the detailed symbolic analytical solution to the drug-delivery problem, and a list of general steps required to solve similar problems. Furthermore, students can complete a series of short activities to get practice with the MATLAB syntax and commands required to solve systems of nonhomogeneous ODEs using three separate approaches:

  1. A linear systems approach employing Eigenvectors and Eigenvalues
  2. A symbolic approach utilizing MATLAB's symbolic toolbox
  3. A numerical approach using MATLAB's Runge-Kutta solver, ode45

At the end of each section in the Live Script, students can complete a series of MATLAB grader problems that provide them with a template that contains the outline of the code structure required to solve the Drug Delivery problem using the three approaches explored in the lab.

MATLAB Live Script of Activities: Drug_Delivery_Problem.mlx (MATLAB Live Script 48kB Nov7 19)

Solution to MATLAB Live Script Activities: Drug_Delivery_Problem_Solution.mlx (MATLAB Live Script 518kB Nov7 19)

Teaching Notes and Tips

Students most often have trouble understanding how to set up the anonymous functions to handle multiple equations. Most often their mistakes will be in trying to apply sequential solutions rather than simultaneous solutions to the systems of ODEs.


The output plots generated by the students as part of the post-lab activities can be compared against the solutions to see whether they were able to complete the assignment. I typically provide the students with the solution to the in-lab activities a few days after the lab period (prior to the assignment being due) so they can compare their code get help on areas where they are stuck before attempting the post-lab.

MATLAB Grader Problems:

References and Resources

MATLAB Documentation for key commands used in the Activity