is there any way that can speedup the process of following code... A and B are 50000x20 matrices..?
1 回表示 (過去 30 日間)
古いコメントを表示
Lakshmi Chodavarapu
2018 年 2 月 20 日
コメント済み: Lakshmi Chodavarapu
2018 年 2 月 20 日
indx=1;
for f=1:length(A)
for b=1:length(B)
if (A(f,1:6)==B(b,1:6))&(A(f,7)==B(b,7))
AA(indx,:)=A(f,[1:7 11]);
BB(indx,:)=B(b,1:11);
else
end
end
indx=indx+1;
end
0 件のコメント
採用された回答
Jos (10584)
2018 年 2 月 20 日
Your looking for corresponding rows in A and B. intersect might help you
[~,ia,ib] = intersect(A(:,1:7), B(:,1:7), 'rows') ;
AA = A(ia,:) ;
BB = B(ib,:) ;
btw, you loop using length. But length only returns the longest of the dimensions. If you want to loop over rows, use size with the dimension argument, as in size(..., 1)
3 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!