help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Numerical Differentiation and Integration of Array Data


From: syberraith
Subject: Re: Numerical Differentiation and Integration of Array Data
Date: Tue, 6 Dec 2011 19:04:32 -0800 (PST)

I was thinking you used the anonymous function to avoid the repeating the
code of the process function.

I understand what your showing there, although I've tried it a number of
different ways, and octave keeps giving me undefined errs.  So when I put
this into a script and try to run it:

a = 2;
b = 3;
one = @(x) a.*x + b;
two = @(x) a.^2.*x + b;
function res = calculate ( f, v )
   res = f(v)  
endfunction
calculate (one, 5)
calculate (two, 4)

I get this:

error: `a' undefined near line 4 column 12
error: evaluating binary operator `.*' near line 4, column 13
error: evaluating binary operator `+' near line 4, column 17
error: called from `?unknown?'
error: evaluating assignment expression near line 8, column 8
error: called from `calculate'
error: near line 11 of file `/home/fred/octave/test4.m'
octave:1> 

I read that all variables in the next higher scope are supposed to be
available to the anonymous function. 

Although it seems the next higher scope in this case is the scope of the
function calculate rather then the the promary scope of the script itself.

--
View this message in context: 
http://octave.1599824.n4.nabble.com/Numerical-Differentiation-and-Integration-of-Array-Data-tp4145498p4167474.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]