How Detect duplicate value in each column and replace first value with zero?
Mostrar comentarios más antiguos
For example
A = [ 5 3 2 5 1 3 1 1 2 2;
5 8 6 6 1 4 4 2 3 3;
7 9 9 7 4 8 10 6 4 7;
8 10 10 9 9 8 10 6 5 7];
In first column 5 duplicate and in five column 1 duplicate I want replace first duplicated values with 0
3 comentarios
Image Analyst
el 1 de Abr. de 2017
Running your code I get:
A =
5 3 2 5 1 3 1 1 2 2
5 8 6 6 1 4 4 2 3 3
7 9 9 7 4 8 10 6 4 7
8 10 10 9 9 8 10 6 5 7
I do NOT see 5 duplicates in column 1. I don't even see 5 values of anything in column 1 which has only 4 elements. In column 5 I do seem 1 duplicate since the 1 of row 1 is duplicated in row 2. But you need to say whether a number is a duplicate if it's adjacent to the same number, or can it appear apart/separate from it. For example, is the third 10 in row 4 a duplicate or not.
But the main problem is you saying there are 5 duplicates in column 1. Explain that.
the cyclist
el 1 de Abr. de 2017
Editada: the cyclist
el 1 de Abr. de 2017
I think they mean that the number 5 is duplicated in the first column, and that the number 1 is duplicated in the fifth column. (Similarly the number 8 is duplicated in the sixth column, and so on.)
Stephen23
el 2 de Abr. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!