Two matrices A and B. B is subset of A(rowwise).I want to check the indexes for which row of B is there in A and do some operation on those indexes of A. I tried like this, works for small matrices but takes time on my matrix.suggest alternative

A=[0 1 2;2 3 4;1 2 3;4 5 6; 9 8 7;3 4 5];
B=[1 2 3;3 4 5;4 5 6 ];
for k=1:length(B)
for j=1:length(A)
if(B(k,:)==A(j,:))
A(j,3)=1; %operation on superset A,changes 3rd column to 1
end
end
end

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2016 年 1 月 6 日

コメント済み:

2016 年 1 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by