Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!j22g2000hsf.googlegroups.com!not-for-mail
From: Ian Taylor <robert.ian.taylor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Integrating function of a function
Date: Sat, 21 Jun 2008 03:24:36 -0700 (PDT)
Organization: http://groups.google.com
Lines: 53
Message-ID: <26b99aa7-3c64-41f1-8799-a6201574483f@j22g2000hsf.googlegroups.com>
References: <39e38ef4-9894-45c8-9b17-e264ccf03233@m44g2000hsc.googlegroups.com> 
NNTP-Posting-Host: 86.147.225.124
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1214043877 26974 127.0.0.1 (21 Jun 2008 10:24:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 21 Jun 2008 10:24:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: j22g2000hsf.googlegroups.com; posting-host=86.147.225.124; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; 
Xref: news.mathworks.com comp.soft-sys.matlab:475144



On 20 Jun, 15:14, Loren Shure <lo...@mathworks.com> wrote:
> In article <39e38ef4-9894-45c8-9b17-e264ccf03233
> @m44g2000hsc.googlegroups.com>, robert.ian.tay...@gmail.com says...
>
>
>
>
>
> > I have a function (let us call it shape), and one example I could use
> > for this is:
>
> > shape =3D hmin + x*x/(2*R)
>
> > so there are three input arguments: x, hmin, R
>
> > I want to integrate 1/(shape*shape) and 1/(shape*shape*shape).
> > I'm having trouble with the syntax needed to do this with quad.
>
> > I know that if I simply wanted to integrate shape, I would use
> > quad(@(x)shape(x,hmin,R),a,b)
>
> > Is it best to define two functions, one being 1/(shape*shape) and the
> > other being 1/(shape*shape*shape), or can I call quad directly in some
> > way ?
>
> > Thanks
>
> Why not just make an anonymous function for the integrand, either
> straight from your formula, or using the function shape?
>
> quad(@(x) 1. / (hmin + x.^2 / (2*R)).^2, a,b) =A0AND
> quad(@(x) 1. / (hmin + x.^2 / (2*R)).^3, a,b)
>
> OR
>
> quad(@(x) 1. / shape(x,hmin,R).^2, a,b) AND
> quad(@(x) 1. / shape(x,hmin,R).^3, a,b)
>
> I didn't try these so they might not be correct, but the idea is there.
>
> --
> Lorenhttp://blogs.mathworks.com/loren/- Hide quoted text -
>
> - Show quoted text -

Thanks for the help. I will try it out. The second suggestion looks
more useful, because at a later date I may want to change the shape
function.

All the best

Ian Taylor
http://www.iantaylor.org.uk/