During Fall of 2021, I took my first MATLAB class, and while I had experience in both Java and Python, MATLAB was brand new to me and something I had only heard about. However, through out the quarter I learned about how important and powerful MATLAB is and some of its many applications throughout engineering. For the final project of this class I wanted to explore some of those applications and create a three dimensional disease tracking system. We had done a similar project to this one previously in the class in two dimensions, but adding the third dimension to it increased the complexity.
The algorithm used to conduct this simulation is based off a Spatial SIR disease tracking program. Essentially the idea is that a few random individuals within a population start off being infected with a disease, and based upon other individuals proximity to the infected individuals they may also eventually become infected. The algorithm continuously calculates the number of susceptible individuals, number of infected individuals, and the number of recovered individuals for each time step using some given information and specific formulas.
The main three formulas governing this information are shown amongst the images on the right. These equations are a set of derivatives describing the change in numbers of susceptible, infected and recovered individuals based upon three given parameters (alpha, beta, and gamma), the sum of the distance from an individual to the infected individual, and the number of individuals surrounding the current individual.
In order to start programing this process, I first needed a set of points in a well defined surface. To do this I used a modified STL file and wrote a program, called 'stlRead.m', that would go through the file, find each unique point and plot them all on the same plot. In addition, stlRead.m would also save all of these locations in a struct variable called 'mesh' that also would contain the index of each of the neighbors of each location.
After having created the mesh, the program then goes through and uses MATLAB's built in ode45 solver as well as the Fourth Order Runge Kutta method to solve at every point the percentage of susceptible, infected, and recovered individuals within each point. The Fourth Order Runge Kutta method, 'rk4.m' function, I wrote iterates through the equations seen above.
The program then plots the change in susceptible, infected and recovered individuals with time for whatever points are specified in the code. The percentage of each of the three possible conditions will always add up to 100%, which can clearly be seen in these graphs.
Next, I wrote an 'animate.m' function, which animates the change in the ratios at every point across the surface. This was done by assigning each of the SIR values to one of the RGB color values (Susceptible - Blue, Infected - Red, Recovered - Green). Doing this allowed me to use each individual points SIR values to directly show the condition of each point at each time step.
Lastly, the 'write2Excel.m' function creates an excel spreadsheet with the SIR values for each point for how ever many time steps are inputted.
This program is by far one of the most complicated and difficult software projects I have ever had However, the results of the program are accurate and extremely satisfying. Taking on this project taught me so much about MATLAB and the limitless capabilities it has as a program.