⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hh_pulse.m

📁 用matlab实现模拟神经元模型
💻 M
字号:
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Integration of Hodgkin--Huxley equations with Euler method
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 clear; %clf;
 % maximal conductances (in units of mS/cm^2); 1=K, 2=Na, 3=R
    g(1)=36; g(2)=120; g(3)=0.3;
 % battery voltage ( in mV); 1=n, 2=m, 3=h
    E(1)=-12; E(2)=115; E(3)=10.6;
 % Initialization of some variables
    I_ext=0; V=-10; x=zeros(1,3); x(3)=1; t_rec=0;
 % Time step for integration
    dt=0.01;
 % Integration with Euler method
    for t=-40:dt:30
      if t==10; I_ext=6.9; end  % turns external current on at t=10
      if t==11; I_ext=0; end   % turns external current off at t=11
   % alpha functions used by Hodgkin-and Huxley
      alpha(1)=(10-V)/(100*(exp((10-V)/10)-1));
      alpha(2)=(25-V)/(10*(exp((25-V)/10)-1));
      alpha(3)=0.07*exp(-V/20);
   % beta functions used by Hodgkin-and Huxley
      beta(1)=0.125*exp(-V/80);
      beta(2)=4*exp(-V/18);
      beta(3)=1/(exp((30-V)/10)+1);
   % Tau_x and x_0 are defined with alpha and beta
      tau=1./(alpha+beta);
      x_0=alpha.*tau;
   % leaky integration with Euler method
      x=(1-dt./tau).*x+dt./tau.*x_0;
   % calculate actual conductances g with given n, m, h
      gnmh(1)=g(1)*x(1)^4;
      gnmh(2)=g(2)*x(2)^3*x(3);
      gnmh(3)=g(3);
   % Ohm's law
      I=gnmh.*(V-E);
   % update voltage of membrane
      V=V+dt*(I_ext-sum(I));
   % record some variables for plotting after equilibration
      if t>=0;
           t_rec=t_rec+1;
           x_plot(t_rec)=t;
           y_plot(t_rec)=V;
           %yk_plot(t_rec)=g(1)*gnmh(1)/10;
           %yna_plot(t_rec)=g(2)*gnmh(2)/50;
      end
    end  % time loop
    plot(x_plot,y_plot); xlabel('Time'); ylabel('Voltage');
    %hold on
    %plot(x_plot,yk_plot,'r');
    %plot(x_plot,yna_plot,'g');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -