From maintainers-request at octave dot org Thu Mar 30 09:24:06 2006 Subject: Re: Bi variate to mono variate functions From: David Bateman To: "John W. Eaton" Cc: Anglade Pierre-Matthieu , maintainers@octave.org Date: Thu, 30 Mar 2006 17:19:39 +0200 John W. Eaton wrote: >To make the latter case work may require some significant changes to >Octave as it means anonymous functions must be able to find values for >unbound parameters in the context where they are defined (and we first >need to understand precisely what the rules are for looking up these >values -- is it done when the function is defined, or when it is used?). > > I defined the function function y = myfun2(x,c) global p; p = 10; y = 1./(x.^3-2*x-c); end and then did the following in matlab >> global p >> p = 5; >> Q = quad( at (x)myfun2(x,p),0,2) Q = -0.4605 >> p = 10; >> Q = quad( at (x)myfun2(x,p),0,2) Q = -0.2043 >> I think this makes it pretty clear that the anonymous variable is evaluated when the anonymous function is declared... Regards David -- David Bateman David dot Bateman at motorola dot com Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary