Quickly access two arrays
1 回表示 (過去 30 日間)
古いコメントを表示
Hi there,
I got a simple question but I just don't get the solution - so sorry for annoyance!
I have two arrays:
A = [ 2 2 1 3 2 1];
B = [1 3];
I want now a logical array for all numbers with A == 2, but only element number B should be true.
C = [ 1 0 0 0 1 0];
As you can see, the first and third "2" of A is now "true", everything else is false. Is there a simple. loop-avoiding-solution? Thanks!
0 件のコメント
採用された回答
Andrei Bobrov
2012 年 4 月 19 日
A = [ 2 2 1 3 2 1];
B = [1 3];
idx = find(A==2);
C(numel(A)) = false;
C(idx(B)) = true;
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!