looping identical numbers and getting row indices

4 views (last 30 days)
I was actually working on a set of array elements, 50X2. The 1st column gives the frame numbers and the second column is the slot numbers. So each column as random numbers and they are repeating. So what I am trying to do in my experiment is as follows. For example I have the following matrix:
A= [ 1 3
4 7
1 6
4 7
1 6
5 3
4 7 ]
Now I need my code to check for all the repeating numbers in column 1. From the above matrix the values 1 and 4 repeats. For value 1, it repeats on row numbers 1, 3 and 5, I need the code to check for the corresponding values from the 2nd column but on the same rows, where value 1 is repeated in the 1st column. This has to be done for all the elements in column 1. After getting the corresponding numbers from column 2, the code should check if those numbers are also same, meaning from the matrix above for value 1 on row numbers 1, 3 and 5 the corresponding values from the 2ndcolumn are 3, 6 and 6. The code should check if these numbers are also same, if not ignore it and if it is same consider it only if it has repeated twice and if it as repeated more than twice then place a value equal to 1 on all those rows but in the 3rd column of the matrix. So basically it should ignore 3 and give the row numbers of the value 6, since it is repeated only twice that is row numbers 3 and 5, but if you see for a value of 4 in the 1stcolumn, the corresponding element in the 2nd column is 7 which even though is the same number it is repeated more than twice so it should be ignored and a value 1 should be placed on all the rows where it is 7 but in the 3rd column. And I wanted to implement this using looping instead of using functions for all the elements in the matrix.
Can anyone help me with this?

Answers (1)

Dinesh Yadav
Dinesh Yadav on 26 Nov 2019
Find the attached code file for the solution. Hope it helps.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!