Logical Operator Matrix Problem
2 ビュー (過去 30 日間)
古いコメントを表示
I have a logical matrix A [m by n], I want to find all rows of A that has only 1 true in that row. Lets assume
A = [1 0; 1 1; 0 0; 0 1]
After my process, I should get
Res = [1 0;0 0;0 0;0 1]
As logical matrix. It needs to only extract 1 true rows from A and make all other rows as false. Res matrix & A matrix have same dimensions
0 件のコメント
採用された回答
per isakson
2012 年 8 月 8 日
Try
A = [true,false; true,true; false,false; false,true];
sss = sum( double(A), 2 );
Res = false( size( A ) );
Res( sss==1, : ) = A( sss==1, : );
>> Res
Res =
1 0
0 0
0 0
0 1
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!