help-octave
[Top][All Lists]

## Re: simple question

 From: Ted Harding Subject: Re: simple question Date: Sun, 28 Sep 1997 19:12:11 +0100 (BST)

```( Re: Message from Terrence Brannon )
>
> Why is this screwing up?
>
> function a = apha(V)
>      n = -0.01*(V+60)
>      d = exp(-(V+60)/10) - 1
>      a = n/d
> endfunction
>
> octave:1> V=linspace(10,20,100);
> octave:2> plot(V,apha(V));
> error: __plt2vv__: vector lengths must match

Because:
octave-2:1> function a = apha(V)
> n = -0.01*(V+60);
> d = exp(-(V+60)/10) - 1;
> a = n/d;
> endfunction
octave-2:2> V=linspace(10,20,100);
octave-2:3> a=apha(V);
octave-2:4> size(a)
ans =

1  1

octave-2:5>

However, if you replace the "a = n/d" with "a = n./d" (component-by-
component division) you should get what I guess you want:
octave-2:5> function a = apha(V)
> n = -0.01*(V+60);
> d = exp(-(V+60)/10) - 1;
> a = n./d;
> endfunction
octave-2:6> V=linspace(10,20,100);
octave-2:7>  plot(V,apha(V));
octave-2:8>
which produced a plot OK (looked like a remarkably good approximation to
a straight line to me ... ).

Cheers,

```