Roger,
thanks a lot. cumtrapz solved the problem, which is great.
Best,
Anna.
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i51hes$8eh$1@fred.mathworks.com>...
> "Anna Kaladze" <anna.kaladze@gmail.com> wrote in message <i50efa$mcb$1@fred.mathworks.com>...
> > Dear all,
> > I have a nonintegrable function, f(u). It is in the inner integral of a double integral, and the inner one has a variable limit of integration. Like this:
> > "Integral [(Integral of f(u), du)] dt"
> > The outer integral (where the integrand is [(Integral of f(u), du)]) has finite limits (40 and 55, and the variable of integration is t). But the inner integral (where integrand is f(u)) has a low limit 0, but the upper limit is t (in principle, t takes the value from 0 to 55). Can someone help me to deal with this issue? The BIG problem is I need to approximate the solution to my problem SOLELY by employing trapz function. I was advised to adhere to quad2d routine. But I must use trapz and only do a numerical approximation (step size 0.01 should be sufficient to get a decent approximation for my purposes). The question is: “how”?
> > P.S. If the inner integral had constant limits, there would have been no problem even for a dummy like myself, but the inner one's upper limit is t. I tried to do some looping and employed arrayfun but I do not think my skills are up there to crack this problem.
> > P.P.S. Let us assume f(u) = u^2 (for the sake of an illustration, although that would be easily integrable).
> > Anna.
>          
> You are still misusing the word "nonintegrable", Anna! If your function were actually nonintegrable neither you nor anyone else be able to integrate it. It would be an illdefined notion.
>
> Your problem is ideal for cumtrapz as the inner integral, which is simply the cumulative form of trapz, and trapz for the outer integral. If you cannot use cumtrapz, you could always call on trapz multiple times with an increasing upper bound, which is just what cumtrapz would do for you.
>
> Roger Stafford
