Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: Calculating the limit of an integral Date: Fri, 30 Mar 2012 21:02:11 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 21 Message-ID: <jl570j$qfs$1@newscl01ah.mathworks.com> References: <jl2mtk$a37$1@newscl01ah.mathworks.com> <jl3017$adm$1@newscl01ah.mathworks.com> <jl4dqc$f8c$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-00-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1333141331 27132 172.30.248.45 (30 Mar 2012 21:02:11 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 30 Mar 2012 21:02:11 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:762728 "Haojie" wrote in message <jl4dqc$f8c$1@newscl01ah.mathworks.com>... > But then I dont know how to use fzero to calculate t, because Q1 - Q2=0 is not a function so cannot be used in fzero. I dont know if you mean this or please correct me if I understand wrong - - - - - - - - - - Do something like this. First write a function: function q = Haojiefun(t) q = quad(@(x) sqrt(t^(2/7)-x.^(2/7)),0,t) ... -quad(@(x) sqrt(x.^(2/7)-t^(2/7)),t,1); return This constitutes a perfectly respectable function of t. For each possible value of t between 0 and 1 there is a corresponding value of q. (You may want to use other quadrature functions, quadl or quadgk. Also you may want to specify error tolerances in them.) Then use this function as a handle into 'fzero'. T = fzero(@Haojiefun,[0,1]); It should return with the desired T root. It is a good practice to first use your (Haojiefun) function (in a for-loop) to make a plot of q versus t to see if there are multiple roots (or any at all) between 0 and 1. (Note: Earlier I asserted that your function (Haojiefun) would have to be able to accept vector inputs, but that is not true. The variable t sent to it by 'fzero' will just be a scalar. However, the functions called on by 'quad' do need to accept vectors, and hence the "x.^(2/7)" notation.) Roger Stafford