Simplifying for-find loop functions to speed up processing
古いコメントを表示
Hi all,
A pretty basic question, but I'm trying to find a more elegant solution to search through a 750,000x5 list to remove entries from a corresponding list when more than three value in any respective row are above a threshold of 10. The long way of doing so that I have is
% mD is a 750000 x 5 matrix containing distances to the nearest 5
% neighbors of the r,c,v point (from knnsearch) in each row
for i = size(r,1):-1:1
if size(find(mD(i,:)>10),2) > 3
r(i) = [];
c(i) = [];
v(i) = [];
end
end
4 件のコメント
Dyuman Joshi
2024 年 1 月 26 日
How does the condition checked depend on the for loop index?
If it does not, then you are effectively deleting the elements (with indices - size(r,1):-1:1)) or not, which can be done directly or not done at all.
Cameron
2024 年 1 月 26 日
Torsten
2024 年 1 月 26 日
Are there more than 3 values in mD row (i) above 10?
But you don't refer to row i of mD in your loop - you refer to the complete matrix mD with your find-command.
Cameron
2024 年 1 月 26 日
採用された回答
その他の回答 (1 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!