octave-maintainers
[Top][All Lists]
Advanced

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

Re: Bi variate to mono variate functions


From: David Bateman
Subject: Re: Bi variate to mono variate functions
Date: Thu, 30 Mar 2006 17:19:39 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.5.20060mdk (X11/20050322)

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(@(x)myfun2(x,p),0,2)

Q =

   -0.4605

>> p = 10;
>>  Q = quad(@(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                                address@hidden
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



reply via email to

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