How to pick maximum value in group?

28 ビュー (過去 30 日間)
ASHA PON
ASHA PON 2022 年 4 月 19 日
コメント済み: ASHA PON 2022 年 4 月 22 日
I have created groups with repeating value in a matrix and elements in the group are matched with matrix having its probability value. Now I have to find the maximum probability value in each group.
Example:
group n =
prob 1 prob 2 prob 3 maxprob prob 5
Expected output:
group n = repeated value
maxprob
  2 件のコメント
Adam Danz
Adam Danz 2022 年 4 月 19 日
Could you provide an actual example?
It sounds like you're looking for the max function.
ASHA PON
ASHA PON 2022 年 4 月 20 日
a=[6 6 5 6 5 6 6]
b=[0.74 0.66 0.58 0.47 0.606 0.705 0.76]
group 1 = 5
0.58 0.606
group 2 = 6
0.74 0.66 0.47 0.705 0.76
Expected output
group 1 = 5
0.606
group 2 = 6
0.76
This is a smaller version of my problem. I need to apply this problem to a large number of group and n*m matrix. Thank you.

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

採用された回答

Adam Danz
Adam Danz 2022 年 4 月 20 日
data = [0.74 0.66 0.58 0.47 0.606 0.705 0.76];
group = [6 6 5 6 5 6 6];
groupsummary(data(:),group(:),'max')
ans = 2×1
0.6060 0.7600
See groupsummary for details.
  1 件のコメント
ASHA PON
ASHA PON 2022 年 4 月 22 日
Thank you so much for your reply. This is what exactly i needed.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 4 月 20 日
findgroups(a). Then splitapply(@max)
  1 件のコメント
ASHA PON
ASHA PON 2022 年 4 月 22 日
Thank you for your reply

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

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by