location of logical matrix
13 ビュー (過去 30 日間)
古いコメントを表示
Hi I have a 10 x 2 logical matrix and I would need to find out the location of the rows which both columns are ones i.e 1 1.
May I know how I may write for this? Thank you!
0 件のコメント
採用された回答
madhan ravi
2019 年 8 月 22 日
編集済み: madhan ravi
2019 年 8 月 22 日
Since you have a logical matrix it’simply:
ix=all(matrix ,2); % logical indexing is efficient
Wanted=find(ix)
6 件のコメント
madhan ravi
2019 年 8 月 22 日
While learning always visualize with a simple and short example to understand what's going on.
その他の回答 (1 件)
KSSV
2019 年 8 月 22 日
Read about ismember
idx = round(rand(10,2)) ;
vec = [1 1] ;
[c,ia] = ismember(idx,vec,'rows') ;
iwant = find(c) ;
idx(c,:)
idx(iwant,:)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!