Create a vector of time values, `X`.
Also create a matrix, `Y`, containing values evaluated
at the irregular intervals in `X`.

X = [1 2.5 7 10]';
Y = [5.2 4.8 4.9 5.1; 7.7 7.0 6.5 6.8; 9.6 10.5 10.5 9.0; 13.2 14.5 13.8 15.2]

Y =
5.2000 4.8000 4.9000 5.1000
7.7000 7.0000 6.5000 6.8000
9.6000 10.5000 10.5000 9.0000
13.2000 14.5000 13.8000 15.2000

The columns of `Y` represent velocity data,
taken at the times contained in `X`, for several
different trials.

Use `trapz` to integrate each column
independently and find the total distance traveled in each trial.
Since the function values are not evaluated at constant intervals,
specify `X` to indicate the spacing between the data
points.

Q = trapz(X,Y)

Q =
82.8000 85.7250 83.2500 80.7750

The result is a row vector of integration values, one for each
column in `Y`. By default, `trapz` integrates
along the first dimension of `Y` whose size does
not equal 1.

Alternatively, you can integrate the rows of a matrix
by specifying `dim = 2`.

In this case, use `trapz` on `Y'`,
which contains the velocity data in the rows.

dim = 2;
Q1 = trapz(X,Y',dim)

Q1 =
82.8000
85.7250
83.2500
80.7750

The result is a column vector of integration values, one for
each row in `Y'`.