How to find the frequency of individual elements in a matrix?
5 ビュー (過去 30 日間)
古いコメントを表示
How do I find the frequencies of all the elements in the matrix attached and also draw a histogram knowing the frequencies of the elements?
0 件のコメント
採用された回答
Dyuman Joshi
2024 年 4 月 4 日
編集済み: Dyuman Joshi
2024 年 4 月 4 日
MATLAB has a in-built function for it - histogram, which does both the operations in single command -
s = load('micro2d (2).mat')
vec = s.Expression1(:).';
val = unique(vec);
h = histogram(vec, [val Inf])
%numbers
val
%corresponding frequencies
freq = h.Values
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!