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!