[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Numerical Differentiation and Integration of Array Data
From: |
Przemek Klosowski |
Subject: |
Re: Numerical Differentiation and Integration of Array Data |
Date: |
Wed, 07 Dec 2011 09:03:24 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 |
On 12/06/2011 10:38 PM, syberraith wrote:
Even this fails to work:
a = 2;
b = 3;
one = @(x) a.*x + b;
two = @(x) a.^2.*x + b;
one(4)
two(5)
error: `a' undefined near line 3 column 12
In Octave you have to explicitly declare global variables to be able to
see them across the 'lexical scopes' of different function definitions.
Anonymous functions don't magically exempt you from that---but they can
capture the values of variables from the scope they are defined in, at
the time they are defined in.
See again what Carlo was showing; adapted to your example, it'd be
a=2;b=3;
one = @(x,a,b) a.*x+b
one_specialized_for_ab = @(x) one(x,a,b)
one_specialized_for_ab(10)
- Re: Numerical Differentiation and Integration of Array Data, (continued)
- Re: Numerical Differentiation and Integration of Array Data, Francesco Potortì, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/07
- Re: Numerical Differentiation and Integration of Array Data,
Przemek Klosowski <=
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/07
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/08
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/09
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/07
- Message not available
- Re: Numerical Differentiation and Integration of Array Data, Carlo de Falco, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/03
Fwd: Re: Numerical Differentiation and Integration of Array Data, Martin Helm, 2011/12/07