From help-request at octave dot org Sat Mar 18 06:55:33 2006 Subject: Re: quadrature of funct. with parameters From: Gorazd Brumen To: help at octave dot org Date: Sat, 18 Mar 2006 13:52:58 +0100 Thanks for the info. that did the job. maybe it is just me, but where is this described in john's book? regards and thanks again, g. guillem at torroja dot dmt dot upm dot es wrote: > Hi again. > > With the anonymous function you are creating a function handle that > is assigned to a variable. Passing a function as an argument > with a string is valid only when the function is defined as a > *real* function. > > Look at this piece of code: > > octave:3> function y=foo(x,a) > >>y=x*a; >>end > > octave:4> f2= at (x) foo(x,2) > f2 = > > at (x) foo (x, 2) > > octave:5> f2(4) > ans = 8 > octave:6> quad(f2,0,2) %you must pass the variable that contains > %the function handle > ans = 4 > > On Fri, Mar 17, 2006 at 08:30:43PM +0100, Gorazd Brumen wrote: > >>Hi Guillem, >> >>Yes, actually parameteres can be defined, but i cant get the thing >>working. If I write >> >>f2 = at (x) f1(x,2); >>f2 (2) >>f2 (3) >>quad ('f2',0,1) >> >>where f1 is defined in a separate file, than the first three lines work, >>but the 4th doesnt. Can you give me hint what i am doing wrong? >> >> >>thanks, >>g. >> >>Guillem Borrell Nogueras wrote: >> >>>Hi >>> >>>Yu can use an anonymous function to reduce the variables if some parameter is >>>known >>> >>>f2= at (x) f(x,2) >>> >>>guillem >>> >>>On Friday 17 March 2006 14:38, Gorazd Brumen wrote: >>> >>> >>>>Hi all, >>>> >>>>Is there a way to do numeric quadrature of a function over >>>>one variables if the function takes as arguments several parameters, >>>>i.e. f = f(x,a), and i just want a quadrature over x. >>>>Aja, and is there a solution not using global variables? >>>> >>>> >>>>thanks a lot, >>>>G. >>> >>> >>-- >>Gorazd Brumen >>Mail: brumen at isb dot unizh dot ch >>WWW: http://valjhun.fmf.uni-lj.si/~brumen >>PGP: Key at http://pgp.mit.edu, ID BCC93240 >> >> >> >>------------------------------------------------------------- >>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 > ------------------------------------------------------------- > > -- Gorazd Brumen Mail: brumen at isb dot unizh dot ch WWW: http://valjhun.fmf.uni-lj.si/~brumen PGP: Key at http://pgp.mit.edu, ID BCC93240 ------------------------------------------------------------- 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 -------------------------------------------------------------