フィルターのクリア

How to group same value data

15 ビュー (過去 30 日間)
barath manoharan
barath manoharan 2023 年 1 月 25 日
コメント済み: barath manoharan 2023 年 2 月 9 日
Iam having 2 6*1 matrix. Now i need to group elements in matrix A based on same value. then i need to choose corresponding elements from matrix B.
For example
A = [0.367;0.264;0.264;0.2345;0.2345;0.367]
B = [01111;00111;10011;10010;10000;01110]
expected output :
group 1 : 0.367
01111,01110
group 2 : 0.264
00111,10011
group 3 : 0.2345
10010,10000
  2 件のコメント
Stephen23
Stephen23 2023 年 1 月 25 日
編集済み: Stephen23 2023 年 1 月 25 日
Numeric data types do not store leading zeros, so what is this array really?:
B = [01111;00111;10011;10010;10000;01110]
Is it in fact a character array or a string array or a categorical array or something else?
Dyuman Joshi
Dyuman Joshi 2023 年 1 月 25 日
OP could be trying to store binary representation of numbers as numeric data.

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

採用された回答

Matt J
Matt J 2023 年 1 月 25 日
G=findgroups(A(:));
splitapply(@(x){x}, B(:),G)
  1 件のコメント
barath manoharan
barath manoharan 2023 年 2 月 9 日
Thank you and your code works as per my requirement

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by