Reputation: 11
I'm trying to generate an action potential of the HH model, and I need to calculate the alphaN rates. However, at a few values, they are 0/0, so I need to use L'hopitals rule. I can't seem to make the script work. Can anyone please help? How do I do an if statement for a range of numbers? Like:
if Vm == -50:-49
syms Vm;
x = diff((0.01.*(10-(Vm+60))));
y = diff((exp((10-(Vm+60))./10)-1));
alphaN = x./y;
else
alphaN = (0.01.*(10-(Vm+60)))./(exp((10-(Vm+60))./10)-1); % l/ms
betaN = 0.125*exp(-(Vm+60)/80); % 1/ms
end
plot(alphaN,Vm)
However, with the above script, I get matrix doesn't agree. How can I make this work? Hopefully it's just something I'm forgetting.
Thanks for the help!
Upvotes: 1
Views: 15022
Reputation: 74940
To test whether Vm
is between a
and b
, you write
if Vm >= a && Vm <= b %# include a and b
To test whether Vm
is any integer between a
and b
if any(Vm == a:b)
Upvotes: 3
Reputation: 25232
You can use a switch/case construct:
Vm_all = -50:50; %all Vm
for ii = 1:length(Vm)
Vm = Vm_all(ii);
switch Vm
case {-50,-49}
syms Vm;
x = diff((0.01.*(10-(Vm+60))));
y = diff((exp((10-(Vm+60))./10)-1));
alphaN(ii) = x./y;
betaN(ii) = NaN;
otherwise
alphaN(ii) = (0.01.*(10-(Vm+60)))./(exp((10-(Vm+60))./10)-1);
betaN(ii) = 0.125*exp(-(Vm+60)/80);
end
end
This way it doesn't matter if your particular values are in a row or whatever, just type them comma separated.
If you have an array with your exceptions like exc = [-50,-49,-12,42]
you can use it as follow for switch/case:
case {exc(:)}
Upvotes: 0