Hi Roger Stafford:
First, thanks a lot for your reply.
I still have a question about quad2d you suggested. Since I have three variables here, if I use qua2d on (v1,h), then h is still a function of (v1, v2).I wonder how quad2d is going to treat v2. Is it able to work and treat v2 as a parameter in the integrand function such as f(v1, v2,h)?
Thanks again
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i7j148$ctl$1@fred.mathworks.com>...
> "dhuan Du" <dupeony@gmail.com> wrote in message <i7igqg$jni$1@fred.mathworks.com>...
> > Hi,
> > In my code I need to calcuate a threedimensional integral using triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax), (xmin,xmax,ymin,ymax) are specifice by exact values, but (zmin,zmax) are going to be the function of x, and y. I run the following code where only v1, v2, h are variable in integral other other symples are predefined constants. However, I got error information provided below. Could anyone help me out? Thanks,
> >
> > F=@(v2, v1,h)(1(0.5*exp(0.717*((h2.5+y*(1/v21/v1))/((2^0.5)*sigama))0.416*((h2.5+y*(1/v21/v1))/((2^0.5)*sigama))^2)))...
> > *(1/((2*pi)^0.5*theta)*exp(((v1vmu)/theta)^2))...
> > *(1/((2*pi)^0.5*theta)*exp(((v2vmu)/theta)^2))...
> > *(1/((2*pi)^0.5*hvar*h)*exp(((log(h)hmean)/theta)^2));
> > eff=triplequad(F,0,120*5280/3600,0,120*5280/3600,0,(2.5+y*(1/v11/v2)));
> >
> > and get error inforamtion:
> >
> > Undefined function or variable 'v1'.
> >
> > Error in ==> Linear_Searchv1 at 41
> > eff=triplequad(F,0,120,0,120,0,(2.5+y*(1/v11/v2)));
>          
> The matlab function triplequad will not accept variable integration limits. The documentation says the following about that:
>
> "triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax) evaluates the triple integral fun(x,y,z) over the three dimensional rectangular region xmin <= x <= xmax, ymin <= y <= ymax, zmin <= x <= zmax."
>
> You might try using quad2d to get the double integral with respect to v1 and h. It does allow the inner integration limits to depend on the outer variable. You would use this to define a function of just v2 alone. You could then use quad or quadgk to take the integral of this function with respect to v2 if the function is properly written to accept vector inputs.
>
> You could run into other kinds of trouble with that integrand you have defined. The variables v2 and v1 become zero at their lower limits and that makes 1/v2 and 1/v1 infinitevalued in the integrand function. triplequad might be unhappy about that even if it turns out to be integrable. You might have to stop just shy of zero.
>
> Roger Stafford
