Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 2.85 KB | None | 0 0
  1. Δt= 0.001;
  2. N= 200000;    
  3. C      = 1.;    
  4. #gnamax = 120;  
  5. gkmax  = 36;  
  6. gl     = 0.3;  
  7. Ena    = 50.;    
  8. Ek     = -77.;    
  9. El     = -54.387;
  10. Iext   = 7;        
  11.  
  12.  
  13. V= zeros(N,1);
  14. m= zeros(N,1);
  15. n= zeros(N,1);
  16. h= zeros(N,1);
  17. t= zeros(N,1);
  18. τm= zeros(N,1);
  19. τn= zeros(N,1);
  20. τh= zeros(N,1);
  21. αm= zeros(N,1);
  22. βm= zeros(N,1);
  23. αn= zeros(N,1);
  24. βn= zeros(N,1);
  25. αh= zeros(N,1);
  26. βh= zeros(N,1);
  27. minfinity= zeros(N,1);
  28. ninfinity= zeros(N,1);
  29. hinfinity= zeros(N,1);
  30. gnamax= zeros(N:1);
  31.  
  32. gnamax[1:50000]=0.01
  33. gnamax[50001:100000]=40
  34. gnamax[100001:150000]=80
  35. gnamax[150001:200000]=120
  36.  
  37. for k=2:N,      
  38.  
  39.  
  40. V[1]=-64.9964;    #Initial condition;
  41. m[1]=0.0530;      #Initial condition;
  42. n[1]=0.3177;      #Initial condition;
  43. h[1]=0.5960;      #Initial condition;
  44.  
  45.  
  46.  
  47.     αm[k] = 0.1 * (V[k-1]+40.) / (1. - exp(-(V[k-1]+40.)/10.));  
  48.     βm[k]  = 4. * exp(-0.0556 * (V[k-1]+65.));
  49.     αn[k] = 0.01 * (V[k-1]+55) / (1. - exp(-(V[k-1]+55.)/10.));  
  50.     βn[k] = 0.125 * exp(-(V[k-1]+65.)/80.);
  51.     αh[k] = 0.07 * exp(-0.05*(V[k-1]+65.));  
  52.     βh[k] = 1. / (1. + exp(-0.1*(V[k-1]+35.)));
  53.  
  54.     minfinity[k]  = (αm[k]) / (αm[k] + βm[k]);
  55.     τm[k]  = 1 / (αm[k] + βm[k]);
  56.     m[k]= (Δt*-m[k-1] + Δt*minfinity[k]) / (τm[k]) + m[k-1];
  57.  
  58.     ninfinity[k]  = (αn[k]) / (αn[k] + βn[k]);
  59.     τn[k]  = 1 / (αn[k] + βn[k]);
  60.     n[k]= (Δt*-n[k-1] + Δt*ninfinity[k]) / (τn[k]) + n[k-1];
  61.  
  62.     hinfinity[k]  = (αh[k]) / (αh[k] + βh[k]);
  63.     τh[k]  = 1 / (αh[k] + βh[k]);
  64.     h[k]= (Δt*-h[k-1] + Δt*hinfinity[k]) / (τh[k]) + h[k-1];
  65.  
  66.     V[k]= (Δt/C)*(gnamax[k]*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];
  67.  
  68. end  
  69.  
  70. max = (N-1) * Δt;          # Value corresponding to the maximal integration step;
  71. t   = 0:Δt:max;            # Init of an array of N elements, with increasing values (i.e. horizontal coordinate);
  72.  
  73. #using PyPlot;                                 # Tells the computer to “add” a package for (later) generating plots;
  74.  
  75. fig = figure("Numerical method",figsize=(12,6));    # Create a new figure, with desired size;
  76.  
  77. #plot(t, V, "r-", label="membrane potential");              # Plot in the current figure, f(x) - the mumerical solution;
  78.  
  79. ax = gca();                                  # Get a "handle" on the current axes;
  80. ax[:set_xlim]((0,200));                        # For axes "ax" set the horizontal limits;
  81. ax[:set_ylim]((-80,60));                     # For axes "ax" set the vertical limits;
  82. grid("on");                                   # "Grid" on;
  83. xlabel("time");# Label of the horizontal axis
  84. ylabel("mV");                          # Label of the vertical axis
  85. title("Action Potential after pharmacology");        # Label of the title, at the top of the figure
  86. legend(borderaxespad=0.5);                     # Add a legend to the current ax
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement