help-octave
[Top][All Lists]
Advanced

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

Re: function definition for integration


From: Paul Kienzle
Subject: Re: function definition for integration
Date: Mon, 22 Mar 2004 08:28:15 -0500

Or you can include the value of the fixed parameters
directly in your wrapper function:

        function x=flotest1(a), x=flotest(a,4); end

You can use inline() from octave-forge as a shorthand for this:

        octave:4> quad(inline('flotest(x,4)'),0,1)
        ans = 4.3333

Paul Kienzle
address@hidden

On Mar 21, 2004, at 10:53 PM, address@hidden wrote:

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




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