צבי
צבי

Reputation: 31

Parameter that has been provided "undefined"

I composed the following ODE file:

function [dndt,dmdt,dhdt,dVdt]=hh(n,m,h,V)
    C=1; GK=36; GNa=120; GL=0.3; EK=-72; ENa=55; EL=-49.4;
    dndt=(1-n)*alphan(V)-n*betan(V);
    dmdt=(1-m)*alpham(V)-m*betam(V);
    dhdt=(1-h)*alphah(V)-h*betah(V);
    dVdt=-1/C*(GK*n^4*(V-EK)+GNa*m^3*h*(V-ENa)+GL*(V-EL));

The function takes 4 parameters, the last of which is the parameter V. (All the alpha and beta functions are defined in their own .m files.)

Now, in octave, I run:

octave:2> ySS=ode45('hh',[0 20],[0.5;0.5;0.5;-60]);
error: 'V' undefined near line 3, column 3
error: called from
    hh at line 3 column 6
    starting_stepsize at line 53 column 5
    ode45 at line 196 column 25

The initial conditions include 4 parameters, the last of which, -60, is supposed to initially define V.

Where even is this mysterious line 3, column 3?

I can enter those same initial conditions directly into the function without running into any problems:

octave:9> [a,b,c,d]=hh(0.5,0.5,0.5,-60)
a = -0.033401
b = -1.8882
c = 0.011287
d = 838.68

I cannot understand what I'm missing.

I tried renaming the variable (thinking maybe octave reserves V for something), but it made no difference; I also tried replacing all the alpha and beta functions with multiplication by 5 (in case there was some issue with those functions), but still got the same error.

Upvotes: 0

Views: 27

Answers (1)

צבי
צבי

Reputation: 31

A comment helped me to fix this, but I want to write up an answer in case anybody else runs into this issue.

An ode function should take only two parameters: time and a vector with any other variables. The following modification fixed my issue:

function [dndt,dmdt,dhdt,dVdt]=hh(t,x)
    n=x(1); m=x(2); h=x(3); V=x(4);

Upvotes: 1

Related Questions