From: "prabhakaran m" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: help with double integration
Date: Thu, 29 Mar 2012 03:45:26 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 57
Message-ID: <jl0lsm$9el$>
References: <jl0dnq$g19$> <jl0jhj$30i$>
Reply-To: "prabhakaran m" <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1332992726 9685 (29 Mar 2012 03:45:26 GMT)
NNTP-Posting-Date: Thu, 29 Mar 2012 03:45:26 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2438980
Xref: comp.soft-sys.matlab:762539

"Roger Stafford" wrote in message <jl0jhj$30i$>...
> "prabhakaran m" <> wrote in message <jl0dnq$g19$>...
> > need help to solve double integration. i have to calculate the fourier constant using the formula.
> > 
> > A(m,n)= double integration of w(x,y)*cos(m*y/r)*cos(2*n*pi*x/L)in the limits(0,L,0,2*pi*R) i have the matrix w(x,y) of size 74*17 and A will also be in the size of 74*17. but i am puzzled with the number of for loops i have to use. here m and n in the formula is also constants m form 1 to 74 and n form 1 to 17. R is radius. L is the length.
> > 
> > been puzzled here. the code below
> > 
> > out = integrnd(x,y);
> > 
> > A(m,n)= w(x,y)*cos(m*y/r)*cos(2*n*pi*x/l);
> > 
> > result = dblquad(@integrnd,0,l,0,2*pi*R);
> > 
> > i know there is big mistake in the code. by seeing the double integration help file, i have did the above part. if somebody helps me with the loops it will be of great help.
> - - - - - - - - -
>   Prabhakaran, isn't this essentially the same question you asked back in 18 Sep 2010 in the thread:
>  ?
>   I still think the answer to your question lies in that thread.  You should reread it over carefully.  As was pointed out there, your problem is unsuited for 'dblquad' or any of the other quadrature routines that require a function handle for the integrand.  Only routines like 'trapz' or others of higher order in the File Exchange that deal with discrete data can be used for this purpose.
>   The difficulty with integrating functions that are only defined on a discrete set of points is that there is uncertainty about the integrand values in between these points.  In trapezoidal integration techniques these values are approximated by straight lines connecting the values at the discrete points.  With higher order routines, polynomials of various orders are used which run through these points, and this sometimes yields more reasonable approximations.  However, you cannot ever expect to obtain precise values with such techniques.  This is inherent in the lack of knowledge about integrand values between the points.  It is the same problem that faces anyone who does interpolation between points of discretely defined data.
> Roger Stafford

yes Roger, its the same question i asked a year and half back. now i again started to do it. yes that thread was excellent by reading that thread only i found i should not use dblquad. rather trapz is the thing i have to deal with.

i have did the code 

R=(94.6/2+.5); %reference radius
for ii=1:length(x)
  for jj=1:lentheta
for m=1:72
    for n=1:15
i2 = [];
      for i=1:length(x)
  for j=1:lentheta
 I2(i,j) =(2/pi*L)* trapz(y,trapz(x,result));

and i have successfully arrived with the solution. also i am sure the solution what i have got is write  or wrong. but i feel odd i might have misplaced the i,j,ii and jj. if you find any mistake can u tell me.