Count repetitions separately in an array
Mostrar comentarios más antiguos
I have this array
A = [1;1;2;2;2;2;2;2;3;1;1;1;1;4;4;4;1;1;1;5;5];
I want Matlab to tell me when the repetition of 1 is greater than 2 for example, but I don't know any function that does this.
Could you help ? Thanks a lot !
1 comentario
Lea Martine Francoise
el 17 de Mzo. de 2023
Respuesta aceptada
Más respuestas (1)
Antoni Garcia-Herreros
el 17 de Mzo. de 2023
Hello Lea,
Try something like this:
% Where 1 would be the number you are looking and 2 the number of repeats
sum(A==1)>2 % True if there are more than two instances of 1 in your array
1 comentario
Lea Martine Francoise
el 17 de Mzo. de 2023
Categorías
Más información sobre Operators and Elementary Operations 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!