Finding the required number of high frequency values from histogram

2 ビュー (過去 30 日間)
pratapaneni Chetan
pratapaneni Chetan 2021 年 9 月 22 日
編集済み: pratapaneni Chetan 2021 年 9 月 23 日
I have a 60032x1 matrix. With the data I have, I made a histogram. I want the three most repeating values from it. I want the bin centres so that i can plot another graph with it.
Can someone help me with this? Thanks in advance :)

採用された回答

Chunru
Chunru 2021 年 9 月 23 日
a = [randn(10000,1)-5; randn(10000,1); randn(10000,1)+5];
histogram(a)
[y,edges] = histcounts(a);
% Use the center of edges as x-axis
x = (edges(1:end-1) + edges(2:end))/2; % bin centre
figure
plot(x, y)
[pks,locs] = findpeaks(y, x)
pks = 1×3
1929 1951 1909
locs = 1×3
-5.2500 0.2500 5.2500
hold on
plot(locs, pks, '*')
  1 件のコメント
pratapaneni Chetan
pratapaneni Chetan 2021 年 9 月 23 日
編集済み: pratapaneni Chetan 2021 年 9 月 23 日
Thank you for helping me out but when I meant i want to plot another graph, I meant that i want to plot the graph of some other matrix vs the peak's corresponding locs. How can this be done?
Note: the other matrix's dimension is 60032x1

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScopes and Data Logging についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by