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 ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: What's wrong with cumtrapz?
Posted: Jun 17, 2013 10:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Yuji Zhang" <> wrote in message
> Hi Bruno~
> Thanks for getting back to me.
> I see. I assumed they were same.
> What do you mean by "(array non-vector) if it important their
> orientation"?

Read the second sentence of this snippet from the documentation:

"Z = cumtrapz(X,Y) computes the cumulative integral of Y with respect to X
using trapezoidal integration. X and Y must be vectors of the same length,
or X must be a column vector and Y an array whose first nonsingleton
dimension is length(X). cumtrapz operates across this dimension. Inputs X
and Y can be complex."

% This works; for vectors, orientation doesn't matter
cumtrapz(1:3, (4:6).')

% This works, since the first nonsingleton dimension of the second input is
3 which is the length of the first input
cumtrapz([1; 2; 3], ones(3, 4))

% This does NOT work, even though the second input is just the transpose of
the second input from the previous example
cumtrapz([1; 2; 3], ones(4, 3))

Steve Lord
To contact Technical Support use the Contact Us link on

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.