Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.31 KB | None | 0 0
  1.  
  2. N=200000;
  3. V=zeros(N,1);
  4. V2=zeros(N,1);
  5.  
  6. G=0.1;
  7. C=1;
  8. E=-70;
  9. Iext=10;
  10. θ=-50
  11. Tarp=1
  12. R=10
  13. Δt=0.01;
  14. t0= t=1 #when I added this command line I obtained multiple spikes. t0 needs to return to the value of t=1.
  15. V[1]=-70;
  16.  
  17.  
  18.  
  19. for k=2:N,
  20.  
  21. V2[k]= V[k]-50
  22. #V[k]= (Δt/C) * (G*(E-V[k-1]+ Iext)) + V[k-1];
  23.  
  24. V[k]=V[k-1]+Δt/(R*C) *(E-V[k-1])+(Δt/C)*Iext
  25.    
  26.  
  27.  
  28.  
  29.         if (V[k] >= θ)
  30.             V[k]=E
  31.             t0=Δt*k
  32.         elseif (Δt*k-t0)<Tarp
  33.             V[k]=E
  34.         else
  35.             V[k]=V[k-1]+Δt/(R*C) *(E-V[k-1])+(Δt/C)*Iext
  36.         end
  37. end
  38.  
  39.  
  40. max = (N-1) * Δt;          # Value corresponding to the maximal integration step;
  41. t   = 0:Δt:max;            # Init of an array of N elements, with increasing values (i.e. horizontal coordinate);
  42.  
  43. using PyPlot;                                
  44.  
  45. fig = figure("Action potential",figsize=(12,6));    
  46. plot(t, V, "r-", label="membrane potential");  
  47. plot(t, V2, "m--", label="membrane potential");          
  48. ax = gca();                                  
  49. ax[:set_xlim]((0,50));                    
  50.  
  51.  
  52. ax[:set_ylim]((-100,60));                    
  53. grid("on");                                  
  54. #xlabel("time (ms)");
  55. #ylabel("mV");                        
  56. title("Action Potential");        
  57. legend(borderaxespad=0.5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement