How to select specific data from array

7 visualizzazioni (ultimi 30 giorni)
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
i wanted to select and compared data in column 2 and 3 row by row to check if there are repeted data in the following row starting from 1st row
For example,
the data in column 2 and 3, row 1 is 1 & 2
1 & 2 is being compared to second row to check if there is any repeated value in column 2 and 3
value 2 is repeated in row 2 thus the process is repeated to compared value 2 & 3 with value in row 3 column 2 and 3

Risposta accettata

Remy Lassalle-Balier
Remy Lassalle-Balier il 17 Dic 2020
Hi,
How about comparing the number of rows of your matrix with the number of rows after passing through the unique function:
Tst = [ 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];
AllRowsAreUnique = size( Tst , 1 ) == size( unique( Tst(:,2:3) , 'rows') , 1 );

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by