Path: news.mathworks.com!not-for-mail From: "Michael Hosea" <Michael.Hosea@mathworks.com> Newsgroups: comp.soft-sys.matlab Subject: Re: Why am I unable to numerically integrate this? Date: Fri, 23 Apr 2010 12:24:20 -0400 Organization: The MathWorks, Inc. Lines: 30 Message-ID: <hqshjk$5e5$1@fred.mathworks.com> References: <hqqciu$ip4$1@fred.mathworks.com> Reply-To: "Michael Hosea" <Michael.Hosea@mathworks.com> NNTP-Posting-Host: hoseam.dhcp.mathworks.com X-Trace: fred.mathworks.com 1272039860 5573 144.212.115.185 (23 Apr 2010 16:24:20 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 23 Apr 2010 16:24:20 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: news.mathworks.com comp.soft-sys.matlab:629228 As already noted, you can move away from 0 slightly. Another alternative is to use QUADGK instead of QUAD. It's not as fast as QUAD on this problem, but it's a lot more accurate, if that matters to you, and it works "out of the box" here (no need to fudge the left endpoint). -- Mike "KC " <vistarak@gatech.edu> wrote in message news:hqqciu$ip4$1@fred.mathworks.com... > Im trying to integrate this expression (k^4*exp(k))/(exp(k) - 1)^2 and > need a matrix of values for different limits of integration . But for some > reason i am getting NaN as the only answer. Any help would be much > appreciated. > So far this is what I have...... > > theta=225; > T=[(1:1:1000)]; > > for n=1:1000 > x(n)=theta/T(n); > Q(n)=quad(@mt2p3b,0,x(n)); > C(n)=9*R*(T(n)/theta)^3*Q(n); > end > > where mt2p3b is a function handle > function INT = mt2p3b(k) > INT=(k.^4).*(exp(k))./(((exp(k))-1).^2); >