help-octave
[Top][All Lists]
Advanced

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

Re: function definition for integration


From: geordie . mcbain
Subject: Re: function definition for integration
Date: Mon, 22 Mar 2004 14:53:21 +1100
User-agent: KMail/1.5.4

Flo:

A simple if inelegant way to pass multivariate functions when only a 
univariate function is expected is to use global variables and a wrapper 
function.

That is, if your integrand function is

        function x = flotest (a, b) x = a^2 + b; endfunction

then write a wrapper:

        function x = flotest1 (a)
         global flotest_b
         x = flotest (a, flotest_b);
        endfunction

define the global variable

        octave> global flotest_b
        octave> flotest_b = 4;

and do the integration:
        
        octave> quad ("flotest1", 0, 1);
        4.3333



On Fri, 19 Mar 2004 08:23 pm, address@hidden wrote:
> Hi,
> Am am using 2.1.40 since 1 week, like it so a far a lot, and would like to
> integrate a function, defined as with
> two variables, whereas I pass on one as number - so as a simple
> example s.th. like this, which doesn't do the trick:
>
> function x=test(a,b)
> x= a^2 + b;
> endfunction
> quad('test(a,4)',0,1)
>
> So how can I pass on variables not values on to a
> defined function ? I
> dont try to do anything symbolic. I looked around a good bit in the
> documentation, but couldn't figure it out.
>
> Any hints are appreciated,
> Thanks a lot,
> Flo
>
>
>
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------



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