Question: The for loop of my Matlab code only iterates once and I don't know how to fix it. Thank you. clc; clear all; close all;
The for loop of my Matlab code only iterates once and I don't know how to fix it. Thank you.
clc; clear all; close all;
t = 0:0.01:15;
cm = 1*10^-6;
gna = 120;
Ena = 115;
gk = 36;
Ek = -12;
gl = 0.3;
El = 10.6;
v = 0;
am = ((25-v)/10)/(-1+exp((25-v)/10));
bm = 4*exp(-v/18);
m(1) = am/(am+bm);
ah = 0.07*exp(-v/20);
bh = 1/(1+exp((30-v)/10));
h(1) = ah/(ah+bh);
an = ((9.5-v)/100)/(-1+exp((9.5-v)/10));
bn = 0.125*exp(-v/80);
n(1) = an/(an+bn);
for i=1:length(t)
Ina(i) = gna.*m(i)^3.*h(i).*(v(i)-Ena);
Ik(i) = gk.*n(i)^4.*(v(i)-Ek);
Il(i) = gl.*(v(i)-El);
if t(i) >= 0.5 && t(i) <= 0.55
Istim = 200;
v(i) = -(Ina(i)+Ik(i)+Il(i)-Istim)/cm;
else
Istim = 0;
v(i) = -(Ina(i)+Ik(i)+Il(i)-Istim)/cm;
end
end
figure(1)
plot(t,v);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
