Downloadable Files for Matlab:

Diffusion Code

Diffusion with Membrane Code

Diffusion with Membrane and Position Code

Diffusion with charge and potential Code

For this project, I modeled both myelinated and unmyelinated axons, simple diffusion, diffusion through a semi-permeable membrane, diffusion through a semi-permeable membrane (while keeping track of position), calculating the Nernst Equation per ion, Diffusion keeping track of charges, Diffusion considering charged ions, and diffusion considering the Goldman equation.

Unmyelinated and Myelinated Axons

For the unmyelinated axon, I modeled like the myelinated axon that we coded for Homework#5 in Dr. Land's section but I had the node spacing very space, approximately 0.005cm, and considered 20 nodes. For this model, the G-leak value had to increase since normally in an axon the G-leak will be lower for a myelinated axon due to all of it's sheaths compared to an unmyelinated axon. The functions starting with alpha and beta correspond to the Hodgkin-Huxley Model. Unmyelinated Axon Code and Myelinated Axon Code Click under Stimulations, on Axons to download the file to see how the code runs. Below are a few examples, notice that in the Unmyelinated axon the propagation fails and is slower than the myelinated axon.
Unmyelinated Propagation:

Unmyelinated Velocity:

Myelinated Propagation:

Myelinated Velocity:

Return to the top of the page


I also tried to simulate the Nernst Equilibrium. To do this I had to go through different steps to build up to writing the code. Although, these steps are useful in trying to understand how ions flow in channels. First, I wrote the code for diffusion, which is like a code for animating a random walk. For the following examples, the red molecules are Potassium, the blue are Sodium and the green are Chloride. Diffusion Function Code and Diffusion Code. Below is an example of Diffusion (requires IE).

Return to the top of the page

Diffusion through semi-permeable Membrane

Next, I had to create a semi-permeable membrane. I did this by using the rand function in Matlab. The light blue line represents the membrane. Notice that as molecules try to diffuse through (shown as molecules on the membrane) some are allowed and others are not. In this case, the Na is much more permeable through the membrane than K. Diffusion Membrane Function Code and Diffusion with Membrane Code. Below is an example of this:

Return to the top of the page

Diffusion through semi-permeable Membrane while keeping track of molecule position

The next step was to determine where the molecules were positioned, whether they were inside the cell or outside. This was done by modifying The diffusion membrane function to include position. Diffusion Membrane Function with Position Code, Diffusion Membrane Function Code. An example of the code working is below:

Return to the top of the page

Diffusion including Nernst Equation

At this point, I incorporated the Nernst Equilibrium Equation calculated for each ion, and showed this value at the bottom of the figure. Calculation of Nernst Equation with Diffusion of Ions Code Three examples are below:

Return to the top of the page

Diffusion through Semi-permeable Membrane, while tracking charge

To keep track of the charges I wrote a function and then in the code I implemented it such that after calculating the placement of charges for that ion; it would update the total positive and negative charges. Number of charges In and Out of Cell Code

Return to the top of the page

Diffusion through Semi-permeable Membrane, while tracking charges and changing movement based on amount of charge in Area

Next I added the complexities of having the charge move based upon concentration of charges and then added impediment of movement with the Ion potentials. Function for changing movement of particles based upon charge and potential.

Return to the top of the page

Diffusion between membrane, including Charge and electric gradient

After this I added calculation of each ion potential and then the membrane potential. Function for changing x positive when charge is included.. Final Code for Nernst and Goldman Equation. Below is an example of the code: Notice that the Sodium ions are very permeable and diffuse through easily. I modeled the electric potential to increase the probability of the ions to not move to the other side.

Ending Equilibirum Potential Values: