MATLAB: Creating a new vector relative to the matrix

vector

I have an example matrix:
1 19:20:43 DC 7,102 V AUTO
2 19:20:44 DC 7,103 V AUTO
3 19:20:44 DC 7,105 V AUTO
4 19:20:45 DC 7,105 V AUTO
5 19:20:46 DC 6,105 V AUTO
6 19:20:47 DC 1,105 V AUTO
7 19:20:48 DC 0 V AUTO
8 19:20:48 DC 0 V AUTO
9 19:20:49 DC 1 V AUTO
10 19:20:50 DC 7,105 V AUTO
Iโ€™ d like to create a new vector, which will assign to time from a first row of matrix (19:20:43) value 1, to time from second row (19:20:44) โ€“ value 2 e.c.t.. But if the time value repeats, assign the same value for both time values. For matrix above, new vector should be t=[1;2;2;3;4;5;6;6;7;8].
I should probably use loop for, and function if, but really donโ€™t know how to do it.
I hope you understood my problem ๐Ÿ™‚

Best Answer

% A = your 10x6 original matrix;
uRows = unique(A, 'rows');
result = zeros(6,1);
for i=1:size(uRows, 1)
cols = find(ismember(A, uRows(i,:), 'rows'));
result(cols) = i;
end