Effacer les filtres
Effacer les filtres

Most Frequent numbers in a Matrix

1 vue (au cours des 30 derniers jours)
João
João le 22 Déc 2013
Commenté : João le 23 Déc 2013
Good night all,
I hope you call help me with this question.
I have a matrix like this in Matlab.
2012 1 1 0
2012 1 1 0
2012 1 1 0
2012 1 1 0
2012 1 1 1
2012 1 1 1
(...)
Now I want to get the most frequent number in groups of 4 rows. For example;
2012 1 1 0
2012 1 1 1

Réponse acceptée

Image Analyst
Image Analyst le 23 Déc 2013
Modifié(e) : Image Analyst le 23 Déc 2013
Perhaps you want the unique() function:
A=[2012 1 1 0
2012 1 1 0
2012 1 1 0
2012 1 1 0
2012 1 1 1
2012 1 1 1];
[C,ia,ic] = unique(A,'rows')
Well, at least it gives you what you asked for, for the matrix you gave. C is exactly what you said the output should be.
  1 commentaire
João
João le 23 Déc 2013
Perfect! Exactly what I want, thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by