Path: news.mathworks.com!not-for-mail From: "prabhakaran m" <prabha.gahon@gmail.com> 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$1@newscl01ah.mathworks.com> References: <jl0dnq$g19$1@newscl01ah.mathworks.com> <jl0jhj$30i$1@newscl01ah.mathworks.com> Reply-To: "prabhakaran m" <prabha.gahon@gmail.com> NNTP-Posting-Host: www-02-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1332992726 9685 172.30.248.47 (29 Mar 2012 03:45:26 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 29 Mar 2012 03:45:26 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2438980 Xref: news.mathworks.com comp.soft-sys.matlab:762539 "Roger Stafford" wrote in message <jl0jhj$30i$1@newscl01ah.mathworks.com>... > "prabhakaran m" <prabha.gahon@gmail.com> wrote in message <jl0dnq$g19$1@newscl01ah.mathworks.com>... > > 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: > > http://www.mathworks.com/matlabcentral/newsreader/view_thread/288859 ? > > 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 L=150; R=(94.6/2+.5); %reference radius x=0:10:150; y=0:5:360; theta=y*pi/180; lentheta=length(theta); result=[]; for ii=1:length(x) for jj=1:lentheta const=0.0; for m=1:72 for n=1:15 I_term=w(ii,jj)*cos((m-1)*y(jj)/R)*cos(2*(n-1)*pi*x(ii)/L); const=const+I_term; end end result(ii,jj)=const; end end i2 = []; for i=1:length(x) for j=1:lentheta I2(i,j) =(2/pi*L)* trapz(y,trapz(x,result)); end end 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.