sum of individual column values using logical operators

3 ビュー (過去 30 日間)
Usman Mussadiq
Usman Mussadiq 2020 年 3 月 23 日
コメント済み: Usman Mussadiq 2020 年 3 月 23 日
x=[2 1 ;-1 1 ;-1 2 ;1 -1 ;5 -1 ]
ind = x(:,2)<0
C = abs(sum(x(ind)))
ind = x(:,2)>0
D= abs(sum(x(ind)))
here, i need only sum of all rows and second column logical values, while it gives the whole if i remove (:,2) and answer will be not appropriate when i add this one. please guide me
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 23 日
CC = abs(sum(x(ind, 2)))
Usman Mussadiq
Usman Mussadiq 2020 年 3 月 23 日
Thanks alot, your contribution means alot to me.

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

回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by