Geoscience Reference
In-Depth Information
each consisting of eight measurements:
clear
data1 = [5 5 8 9 13 13 13 15];
data2 = [3 3 4 5 5 8 10 16];
We concatenate the two samples horizontally and sort the measurements in
ascending order by typing
data = horzcat(data1,data2);
data = sort(data)
which yields the output
data =
Columns 1 through 8
3 3 4 5 5 5 5 8
Columns 9 through 16
8 9 10 13 13 13 15 16
autowrapping those lines that are longer than the width of the Command
Window. We then determine the number of measurements
n1
and
n2
in
each sample, which is eight for both of the samples in our example. h en we
create a linearly-spaced vector
L
ranging from
1
to
length(data)
.
n1 = length(data1);
n2 = length(data2);
L = 1 : length(data)
which yields
L =
Columns 1 through 8
1 2 3 4 5 6 7 8
Columns 9 through 16
9 10 11 12 13 14 15 16
We next i nd the unique values
C
in the data. h e location vectors
ia
and
ic
help to i nd
C = data(ia)
and to reconstruct data from
data = C(ic)
.
We then search for tied values in
data
. At er we have initialized the
variables by setting them all to zero, the tied values in
ic
are located using
find
and are then stored in
dties
, with the number of occurrences recorded
in
nties
. Having located the tied values their ranks are averaged and stored
in
icf
. We type
nties = 0;
dties = 0;
kties = 0;