how to call the data in matrix with the same value in one column

2 ビュー (過去 30 日間)
ha ha
ha ha 2017 年 11 月 18 日
コメント済み: ha ha 2017 年 11 月 21 日
Let's say:
A= [ 111 111 111 2 % group 1
999 999 999 2 % group 1 ...........
555 555 555 4 % group 2
222 222 222 4 % group 2
333 333 333 4 % group 2 ...........
123 311 911 7 % group 3
221 199 722 7 % group 3 ...........
699 996 331 8 ] % group 4
Note: IF the value of column 4 in matrix A is the same, so all data will be grouped in one group
My question is: How to call each group from matrix A? Since, I wanna work with the data in each group? I hope the result:
A1= [ 111 111 111 2 % point 1
999 999 999 2] % point 2
A2= [ 555 555 555 4 % point 3
222 222 222 4 % point 4
333 333 333 4 ] % point 5
.................. and so on.

採用された回答

KL
KL 2017 年 11 月 18 日
編集済み: KL 2017 年 11 月 18 日
first get all the unique values of column 4 using,
vals = unique(A(:,4));
then use indexing to filter,
A(A(:,4)==vals(1),:)
better idea is to use to tables and then use use findgroups
  1 件のコメント
ha ha
ha ha 2017 年 11 月 21 日
Thank @KL
You know how to calculate how many point in each group? Exam: group 1 contain 2 points, group 3 contain 3points.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by