Using Trapz/Cumtrapz- what is unit spacing

17 views (last 30 days)
Annemarie
Annemarie on 13 May 2013
I'm using the cumtrapz and trapz functions, and integrating from acceleration to get a displacement value. The data is collected over even time intervals for 120 data points. I'm simply not sure I understand what is meant by "unit spacing". I don't know if I should be dividing the integral by 120 or not.
%Should my code read something like:
vel = cumtrapz(acc)/120 %where acc = <120x1 double>
disp = trapz(vel)/120 %from above, vel = <120x1 double>
I feel that because the spacing between points is a time instant which is constant you don't need to be dividing by 120 but perhaps I am wrong?
Could someone please clarify for me what "unit spacing" means and when you would use a spacing increment.

Answers (1)

Matt J
Matt J on 13 May 2013
Edited: Matt J on 13 May 2013
trapz(Y) and cumtrapz(Y) assume the spacing between your time samples Y(i) is 1. If it is not 1, you should multiply the result by the spacing you want.
  2 Comments
Annemarie
Annemarie on 13 May 2013
Thank you, just to clarify, therefore if you multiplied the cumtrapz(acc) by a specific spacing increment, you would need to also multiply the traz(vel) by the same spacing increment? (ie the spacing of the vel is not being set to 1 through the use of cumtrapz).
Matt J
Matt J on 13 May 2013
Yes, all integration operations need to be told their spacing increment.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!