The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: What's wrong with cumtrapz?
Replies: 7   Last Post: Jun 17, 2013 10:52 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 30
Registered: 6/27/11
Re: What's wrong with cumtrapz?
Posted: Jun 16, 2013 1:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

nice explanation!

Rick, there is:
if F'(x) = f(x), then
integral f(x) dx = F(x) + C C is any constant

so the integral result has some shift along y axis. The shift should be determined by boundary conditions.

"Timothy E. Vaughan" <> wrote in message <9cu9jh$doh$>...
> ""Leung, Randolph [COPE/HKG]"" <> wrote in message

> >
> > I have some experimental time traces to integrate. CUMTRAPZ seems
> > to be a simple and easy option for me. To test it, I tried to integrate a
> > simple SIN(X) time trace as follows,
> >
> > x = 0:pi/100:4*pi];
> > y = sin( 2*pi*x).
> >
> > inty = cumtrapz( x', y' );
> >
> > I would expect a COS(X) time trace after CUMTRAPZ. The integrated
> > time trace gave a cos pattern of variation, correct amplitude BUT was
> > wrong in phase and shifted upwards, i.e. it is greater than zero for all
> > x and gives 0, rather than 1, at x = 0. I am very confused with the
> > results.

> It seems you may be forgetting a bit of your calculus. You are numerically
> taking the INDEFINITE integral of your function. In that case, you must be
> prepared to add a constant to your solution. [I think it is really only
> shifted "upward", and not really wrong in phase.] You need to determine the
> appropriate constant from other conditions of your problem.
> Tim

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.