필터 지우기
필터 지우기

Most Frequent numbers in a Matrix

조회 수: 1 (최근 30일)
João
João 2013년 12월 22일
댓글: João 2013년 12월 23일
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

채택된 답변

Image Analyst
Image Analyst 2013년 12월 23일
편집: Image Analyst 2013년 12월 23일
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
João
João 2013년 12월 23일
Perfect! Exactly what I want, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by