Search All of the Math Forum:

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

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

 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

"Yuji Zhang" <yuji.zhang@tufts.edu> wrote in message
news:kpkfsc\$6r9\$1@newscl01ah.mathworks.com...
> 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"?

http://www.mathworks.com/help/matlab/ref/cumtrapz.html

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
slord@mathworks.com