# MATLAB: How to determine repeated value in row of an array

matrix arrayrepeat value

I have a data of
1 1 2 2
2 2 3 1.5
3 3 4 2.2
4 4 5 6.8
5 4 6 1
6 5 7 5.1
7 6 8 2.5
8 7 9 3.3
9 8 10 2.8
10 8 11 1.4
11 10 12 3.2
12 11 13 2.7
13 12 14 1.9
14 13 15 4.5
How can i create a code to have it to check on each row if the value is repeated.
As an example:
The value that i wanted to check is on row 4 column row 2 and 3.
The value selected is 4 and 5. These value are then being compared with the value of the row below it.
If the value in the following row which is row 5 have value that are same with the value above which is 4, it will continue this comapring process with the value 4 and 6 with another row until there is no other identical appear.
After identifying all repeative value, the value in column 4 of those repeative value are being added together.

A = [1	1	2	22	2	30	1.53	20	4	2.24	4	5	6.85	4	6	16	20	70	5.17	6	30	2.58	7	9	3.3]vals = [4 ,20, 30, 70, 5];sumVals = nan(numel(vals), 1); % NaN for values not satisfying the conditionfor i = 1:numel(vals)    checkMe = find(any(A == vals(i), 2)); % find all rows containing vals(i)    if ~isempty(diff(checkMe)) && all(diff(checkMe) == 1)% if vals(i) appreas in consecutive rows and appears at least twice        sumVals(i, 1) = sum(A(checkMe, end)); % sum over last column    endendsumVals   10.0000       NaN       NaN       NaN    7.8000