Compute the mean of a bucket

3 ビュー (過去 30 日間)
Maia2022
Maia2022 2022 年 10 月 26 日
コメント済み: Steven Lord 2022 年 10 月 26 日
Hello,
I have this sorted array (15 x2):
A = [
9.5690 245.5560;
11.2911 183.8890;
11.6965 190.4440;
13.4213 181.6670;
13.6207 163.0000;
15.6435 155.4440;
32.2641 121.3330;
34.8958 108.5560;
35.2021 129.8890;
37.3774 92.6667;
37.6286 129.4440;
39.8975 126.7780;
40.2312 122.0000;
42.3333 133.3330;
58.3510 23.0000];
I'd like to create 5 bins for A(:, 1) and compute the mean of A(:,2) wrt to the corresponding bin.
How could I do this without histcount() ?
Thank you
  1 件のコメント
Matt J
Matt J 2022 年 10 月 26 日
How could I do this without histcount() ?
Why is there a need to avoid histcounts?

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

回答 (1 件)

Matt J
Matt J 2022 年 10 月 26 日
編集済み: Matt J 2022 年 10 月 26 日
bins = discretize(A(:,1),5);
averages = splitapply(@mean,A(:,2), bins)
  1 件のコメント
Steven Lord
Steven Lord 2022 年 10 月 26 日
You could also use groupsummary instead of splitapply.

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

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by