Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trapz step size

100 views
Skip to first unread message

Pg

unread,
Mar 17, 2011, 12:41:05 PM3/17/11
to
Hi,

I want to use numerical integration command trapz. My data is a vector and n't a function. and I want to fix a step size other than 1. How to fix this step size as in help menu it is written I need to multiply the output with step size, which I couldn't understood. If any body shows any script file will be quite helpful for me.

Steven_Lord

unread,
Mar 17, 2011, 1:13:30 PM3/17/11
to

"Pg " <poulo...@gmail.com> wrote in message
news:iltdj1$d33$1...@ginger.mathworks.com...

Let's look at the reference page for TRAPZ.

http://www.mathworks.com/help/techdoc/ref/trapz.html

The section you're citing is:

"Z = trapz(Y) computes an approximation of the integral of Y via the
trapezoidal method (with unit spacing). To compute the integral for spacing
other than one, multiply Z by the spacing increment. Input Y can be
complex."

Note that this ONLY applies to the 1-input form of TRAPZ. The corresponding
line for the 2-input form of TRAPZ makes no mention of spacing, as TRAPZ can
determine the spacing from the X vector.

"Z = trapz(X,Y) computes the integral of Y with respect to X using
trapezoidal integration. Inputs X and Y can be complex."

Therefore I recommend you construct your X and Y vectors and pass them both
into TRAPZ as is done in all three of the examples on the reference page.
Example 1 uses a uniform spacing (with a step size other than 1) between the
data points; example 2 uses nonuniform spacing between the points.

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

0 new messages