How to check if all the numbers in a column of a matrix are equal and return that value
조회 수: 20 (최근 30일)
이전 댓글 표시
I am trying to construct a way to find a column of equal numbers in matrix of any size. There will only be one column where the numbers are equal. I then need to extract that number (the number that is the same throughout the column) to a variable that can be called on. I have tried for loops, but I cannot get it to work. Any help would be greatly appreciated.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 11월 2일
편집: Azzi Abdelmalek
2013년 11월 2일
If A is your matrix
idx=find(all(~diff(A)))
out=A(1,idx)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!