Why do I receive an error when running this code?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I keep getting an error next to my Jk and IL under 2). I am unsure how to fix it.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Template for Hodgkin Huxley model of action potential
% in a giant squid axon
% Complete the code by inserting appropriate expressions
% in the places marked
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define constants here
Vrest = -60 ; % resting potential, mV
ENa = 52.4 ; % sodium Nernst potential, mV
gNa_max = 120 ; % sodium saturation conductance, mS/cm2
Cm = 1 ; % membrane capacitance, uF/cm^2
1) Define other constant related to IK and IL here
% Define other constants related to IK and IL here
Ek = -72.1 ; % potassium Nernst potential, mV
EL = -49.2 ; % leak Nernst potential, mV
% time stepping and stimulus related constants
deltaT = 0.01 ; % time step, millisec
tStart = -1.000 ; % start time, millisec
tEnd = 15.000 ; % end time, millisec
nStep = ceil((tEnd-tStart)/deltaT) ; % number of time steps
outputInterval = 20 ; % number of time steps between screen output
StimDur=2; % duration of the stimulus, millisec
Jstim=150; % strength of stimulus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set initial value of state variables
Vm = Vrest ; % membrane potential, mV
m = 0.05293 ; % initial value of m gate
2) similarly, declare initial values of h and n gates here
h = 0.59612 ; % h gate value
n = 0.31768 ; % n gate value
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Storage for variables to plot
plot_Vm = zeros(nStep,1) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Print a heading for the screen output
disp('Hodgkin-Huxley squid axon model')
fprintf('\t Time \t Vm \t n \t\t m \t\t h\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Start the simulation
tNow = tStart ;
for iStep = 1:nStep
% Compute ion currents & stimulus current
JNa = gNa_max*m*m*m*h*(Vm-ENa) ;
Jk = gk_max*m*m*m*H*(Vm-Ek) ;
IL = gL_max*m*m*m*H*(Vm-EL) ;
3) write similar expressions for JK and IL here
if( 0<=tNow && tNow<StimDur ) % apply stimulus current at t=0
Jm = Jstim ;
else
Jm = 0 ;
end
% Compute gates' opening and closing rates
alpha_m = 0.1*(25-Vm)/(exp(0.1*(25-Vm))-1);
beta_m = 4*exp(-Vm/18);
m = m + deltaT*(alpha_m*(1-m)-beta_m*m);
4) Write similar expressions for n and h gates here
alpha_n = 0.1*(10-Vm)/(exp(0.1*(10-Vm))-1);
beta_n = 0.125*exp(-Vm/80);
n = n + deltaT*(alpha_n*(1-n)-beta_n*n);
alpha_h = 0.07*exp(-Vm/20);
beta_h = (exp((30-Vm)/10)+1)^-1;
h = h + deltaT*(alpha_h*(1-h)-beta_h*h);
% Compute change in state variables
deltaVm = -deltaT * (JNa + JK + JL - Jm)/Cm ;
% Record/display state variables & other values
plot_Vm(iStep) = Vm ;
plot_time(iStep) = tNow ;
if mod(iStep,outputInterval) == 0
fprintf('%8.2f %7.3f %7.5f %7.5f %7.5f\n', ...
tNow, Vm, n, m, h) ;
end % if mod(tNow)
% Update state variables
Vm = Vm + deltaVm ; % new Vm = current Vm + change in Vm
tNow = tStart + iStep*deltaT ; % increment the time
end % for iStep
% Plot the gates, probabilities, currents, Vm, etc
plot(plot_time, plot_Vm); grid on ;
5) Similarly plot gates n, m and h against time
end of file
1 commentaire
Réponses (1)
David Hill
le 13 Oct 2022
You have not defined several variables: gk_max, gL_max, H, JK, JL. Once you define these variable the code will run.
gk_max=1;gL_max=1;H=1;JK=1;JL=1; %you need to define these variables.
Vrest = -60 ; % resting potential, mV
ENa = 52.4 ; % sodium Nernst potential, mV
gNa_max = 120 ; % sodium saturation conductance, mS/cm2
Cm = 1 ; % membrane capacitance, uF/cm^2
% Define other constants related to IK and IL here
Ek = -72.1 ; % potassium Nernst potential, mV
EL = -49.2 ; % leak Nernst potential, mV
% time stepping and stimulus related constants
deltaT = 0.01 ; % time step, millisec
tStart = -1.000 ; % start time, millisec
tEnd = 15.000 ; % end time, millisec
nStep = ceil((tEnd-tStart)/deltaT) ; % number of time steps
outputInterval = 20 ; % number of time steps between screen output
StimDur=2; % duration of the stimulus, millisec
Jstim=150; % strength of stimulus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set initial value of state variables
Vm = Vrest ; % membrane potential, mV
m = 0.05293 ; % initial value of m gate
h = 0.59612 ; % h gate value
n = 0.31768 ; % n gate value
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Storage for variables to plot
plot_Vm = zeros(nStep,1) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Print a heading for the screen output
disp('Hodgkin-Huxley squid axon model')
fprintf('\t Time \t Vm \t n \t\t m \t\t h\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Start the simulation
tNow = tStart ;
for iStep = 1:nStep
% Compute ion currents & stimulus current
JNa = gNa_max*m*m*m*h*(Vm-ENa) ;
Jk = gk_max*m*m*m*H*(Vm-Ek) ;
IL = gL_max*m*m*m*H*(Vm-EL) ;
if( 0<=tNow && tNow<StimDur ) % apply stimulus current at t=0
Jm = Jstim ;
else
Jm = 0 ;
end
% Compute gates' opening and closing rates
alpha_m = 0.1*(25-Vm)/(exp(0.1*(25-Vm))-1);
beta_m = 4*exp(-Vm/18);
m = m + deltaT*(alpha_m*(1-m)-beta_m*m);
alpha_n = 0.1*(10-Vm)/(exp(0.1*(10-Vm))-1);
beta_n = 0.125*exp(-Vm/80);
n = n + deltaT*(alpha_n*(1-n)-beta_n*n);
alpha_h = 0.07*exp(-Vm/20);
beta_h = (exp((30-Vm)/10)+1)^-1;
h = h + deltaT*(alpha_h*(1-h)-beta_h*h);
% Compute change in state variables
deltaVm = -deltaT * (JNa + JK + JL - Jm)/Cm ;
% Record/display state variables & other values
plot_Vm(iStep) = Vm ;
plot_time(iStep) = tNow ;
if mod(iStep,outputInterval) == 0
fprintf('%8.2f %7.3f %7.5f %7.5f %7.5f\n', ...
tNow, Vm, n, m, h) ;
end % if mod(tNow)
% Update state variables
Vm = Vm + deltaVm ; % new Vm = current Vm + change in Vm
tNow = tStart + iStep*deltaT ; % increment the time
end % for iStep
% Plot the gates, probabilities, currents, Vm, etc
plot(plot_time, plot_Vm); grid on ;
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
