Advertisement
Guest User

Untitled

a guest
Nov 29th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 3.17 KB | None | 0 0
  1. Δt= 0.01;  #the formula will work with timesteps of 0,01
  2. N= 50000;    #This will be the size of the array and subsequently the amount of integration steps. You divide (x*N)/Δt = amount of N needed for a certain timeframe.
  3.        
  4.  
  5. C      = 1.;    # This is the membrane (specific) capacitance [uF/cm^2]
  6. gnamax = 120;   # This is the membrane max (specific) sodium conductance [mS/cm^2]
  7. gkmax  = 36;    # This is the membrane max (specific) potassium conductance [mS/cm^2]
  8. gl     = 0.3;   # This is the membrane max (specific) leak conductance [mS/cm^2]
  9. Ena    = 50.;     # This is the reversal potential for sodium currents [mV]
  10. Ek     = -77.;    # This is the reversal potential for potassium currents [mV]
  11. El     = -54.387; # This is the reversal potential for leak currents [mV]
  12.  
  13.  
  14.  
  15.  
  16. V= zeros(N,1); #This command will make the array defined by the number N earlier and fill it with zeros;
  17. m= zeros(N,1);
  18. n= zeros(N,1);
  19. h= zeros(N,1);
  20. t= zeros(N,1);
  21. τm= zeros(N,1);
  22. τn= zeros(N,1);
  23. τh= zeros(N,1);
  24. αm= zeros(N,1); #because alpha and beta are dependent of "V" and "V" is dependent of time, both of these formulas are vectors and should be put in an array;
  25. βm= zeros(N,1);
  26. αn= zeros(N,1);
  27. βn= zeros(N,1);
  28. αh= zeros(N,1);
  29. βh= zeros(N,1);
  30. minfinity= zeros(N,1);
  31. ninfinity= zeros(N,1);
  32. hinfinity= zeros(N,1);
  33.  
  34. V[1]=-64.9964;    #This is the resting membrane potential?????? Initial condition; These initial conditions were one cause of the error. I put them before the zeros(N,1) arrays which caused them to be overwritten.
  35. m[1]=0.0530;      #Initial condition;
  36. n[1]=0.3177;      #Initial condition;
  37. h[1]=0.5960;      #Initial condition;
  38.  
  39. Iext=7;           #I played with the input current to find the current at which I started getting a train of AP's;
  40.  
  41. for k=2:N,        #This will start the loop #Not sure what to put at the question mark k=???:N;
  42.  
  43.  
  44.    
  45.     αm[k] = 0.1 * (V[k-1]+40.) / (1. - exp(-(V[k-1]+40.)/10.));  #because V is unknown and you have starting point V(1) you can calculate the rest;
  46.     βm[k]  = 4. * exp(-0.0556 * (V[k-1]+65.));
  47.     αn[k] = 0.01 * (V[k-1]+55) / (1. - exp(-(V[k-1]+55.)/10.));  
  48.     βn[k] = 0.125 * exp(-(V[k-1]+65.)/80.);
  49.     αh[k] = 0.07 * exp(-0.05*(V[k-1]+65.));  
  50.     βh[k] = 1. / (1. + exp(-0.1*(V[k-1]+35.)));
  51.  
  52.  
  53.     minfinity[k]  = (αm[k]) / (αm[k] + βm[k]); #This is where the error started. No matching method found;
  54.     τm[k]  = 1 / (αm[k] + βm[k]);
  55.     m[k]= (Δt*-m[k-1] + Δt*minfinity[k]) / (τm[k]) + m[k-1];
  56.  
  57.    
  58.  
  59.     ninfinity[k]  = (αn[k]) / (αn[k] + βn[k]);
  60.     τn[k]  = 1 / (αn[k] + βn[k]);
  61.     n[k]= (Δt*-n[k-1] + Δt*ninfinity[k]) / (τn[k]) + n[k-1];
  62.  
  63.    
  64.  
  65.     hinfinity[k]  = (αh[k]) / (αh[k] + βh[k]);
  66.     τh[k]  = 1 / (αh[k] + βh[k]);
  67.     h[k]= (Δt*-h[k-1] + Δt*hinfinity[k]) / (τh[k]) + h[k-1];
  68.  
  69.     V[k]= (Δt/C)*(gnamax*m[k-1]^3*h[k-1]*(Ena - V[k-1]) + gkmax*n[k-1]^4*(Ek - V[k-1]) + gl*(El - V[k-1]) + Iext) + V[k-1]; # This is the hodgkin & huxley model
  70.  
  71. end  
  72.  
  73. max = (N-1) * Δt;          # Value corresponding to the maximal integration step;
  74. t   = 0:Δt:max;            # Init of an array of N elements, with increasing values (i.e. horizontal coordinate);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement