How to classify vectors based on their value?

1 回表示 (過去 30 日間)
Robin Li
Robin Li 2019 年 5 月 16 日
コメント済み: Robin Li 2019 年 5 月 16 日
Suppose I have a 3 by 2 matrix C=[1 2; -2 3; 4 -5]; we could also view it as three vectors(1 2), (-2 3) and (4,-5). I want to classify these three vectors into 2 group; whenever the sum of the vector value(for example, the sum of (1 2) is 1+2=3) is greater than 0, then it goes to catagory A; otherwise goes to B.
How could I do this in Matlab?
Thank you!

採用された回答

madhan ravi
madhan ravi 2019 年 5 月 16 日
idx=sum(C,2)>0;
A=C(idx,:)
B=C(~idx,:)
  1 件のコメント
Robin Li
Robin Li 2019 年 5 月 16 日
Thank you:))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by