How to print most repeated Value in MATLAB

2 ビュー (過去 30 日間)
Med Future
Med Future 2022 年 12 月 17 日
回答済み: Steven Lord 2022 年 12 月 17 日
I have the following array, I want to print the value which is repeated mostly in array.
How can i do that in MATLAB

回答 (2 件)

Steven Lord
Steven Lord 2022 年 12 月 17 日
x = randi(5, 6, 6)
x = 6×6
2 4 4 4 2 5 1 4 2 1 5 4 2 4 5 3 5 1 2 1 5 4 5 5 5 3 3 3 1 4 1 2 1 2 5 3
mostCommonInColumns = mode(x)
mostCommonInColumns = 1×6
2 4 5 3 5 4
mostCommonInMatrix = mode(x, 'all')
mostCommonInMatrix = 5

KSSV
KSSV 2022 年 12 月 17 日
a = [1 2 2 2 3 3 4 4 4] ;
[c,ia,ib] = unique(a);
C = accumarray(ib,1) ;
[c' C]
ans = 4×2
1 1 2 3 3 2 4 3
  3 件のコメント
Med Future
Med Future 2022 年 12 月 17 日
@KSSV Its not working on the dataset I have attached
Voss
Voss 2022 年 12 月 17 日
@Med Future: The dataset you have attached contains 492 unique values. That is, there are no repeated values.
load reprctedvalue
numel(clusters1)
ans = 492
numel(unique(clusters1))
ans = 492

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by