help-octave
[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 09:50:02 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.5.20060mdk (X11/20050322)

Thomas Shores wrote:

>On Wednesday 29 March 2006 15:32, David Bateman wrote:
>  
>
>>Anglade Pierre-Matthieu wrote:
>>    
>>
>>>Hi all,
>>>
>>>I've some kind of very dumb problem with octave's synthax.
>>>probably because I don't mastered it at all I'm not able to
>>>solve the following problem:
>>>
>>>I have a function which look like having two variables but have
>>>in fact a single one and I can't find the way to tell this to
>>>octave. Here is the function (LateX form):
>>>f(x) = \int_a^b g(x,y) dy
>>>
>>>In order to compute that I first define g(x,y)
>>>Then I'd like to use the "quad" function to get the integral
>>>over the range o "y" values.
>>>but I d'ont find the way to tell quad that my function is now
>>>g(x,y) but with a fixed "x" value.
>>>
>>>Obviously I need to do this on the fly ( i.e. I can't define a
>>>function for each value of x) because otherwise it would take
>>>too long to get a complete plot...
>>>
>>>Could anybody kindly help me?
>>>
>>>
>>>--
>>>Pierre-Matthieu Anglade
>>>      
>>>
>>There is currently no way to do this, though funnily I just
>>implemented it with the attached patch I'm working on in another
>>thread about importing octave-forge changes into octave. So if
>>you want to rebuild octave the you have the patch :-)
>>
>>D.
>>    
>>
>
>True, you can't do it in a straightforward manner, but if you're 
>willing to live with globals, you can get this job done by creating 
>only one auxiliary wrapper function once and for all:
>
>octave:2> global x
>octave:3> function retval = gx(y)
>  
>
>>global x
>>retval = g(x,y);
>>end
>>    
>>
>octave:4> % now make up any g(x,y) you want, but not anonymous
>octave:4> function retval = g(x,y)
>  
>
>>retval = x.^2 +y.^2;
>>end
>>    
>>
>octave:5> x = 1;
>octave:6> quad('gx',0,1)
>ans = 1.3333
>octave:7> x = 0;
>octave:8> quad('gx',0,1)
>ans = 0.33333
>
>  
>
True, but then it not a function with two variables. Its a function with
one variable and a global. This is a question that comes up often and
all of the possible solutions have been discussed. My mail was more
about the coincident that the decrufting of octave-forge might get rid
of this issue...

D.

-- 
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



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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