フィルターのクリア

Find multiple true in same row

5 ビュー (過去 30 日間)
Millone
Millone 2015 年 5 月 29 日
コメント済み: Millone 2015 年 5 月 29 日
I am trying to detect if there is more than one true in the same column of a matrix:
A=[1 0 0; 1 0 0]
r= sum(A,2);
check=sum(r>1)
if check ==0
out= 'single';
else
out='multiple';
but it does not work I do not understand why? And to achieve the same for columns I have used:
col= sum(A);
check=sum(col>1)
if check ==0
out= 'single'
else
out='multiple'
this seems to work for columns.
Is there a better way to check separately if there are multiple true in rows and columns?

採用された回答

per isakson
per isakson 2015 年 5 月 29 日
編集済み: per isakson 2015 年 5 月 29 日
Hint:
>> A=[1 0 0; 1 0 1]
A =
1 0 0
1 0 1
>> B = A==1
B =
1 0 0
1 0 1
>> sum( B, 1 )
ans =
2 0 1
>> sum( B, 2 )
ans =
1
2
>>
with A(end,end)==1
  1 件のコメント
Millone
Millone 2015 年 5 月 29 日
Thanks for the hint

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by