How can I make the following for loop faster without exceeding the memory limit?
2 ビュー (過去 30 日間)
古いコメントを表示
EX.
% remove these indices from faces (really long array)
pt_indices = [1 357 472 10035 ...];
faces = N x 3 matrix (extremely large matrix)
% reverse order so indices to be removed do not change
for i = length(pt_indices):-1:1
sel = faces>pt_indices(i);
faces(sel) = faces(sel) - 1; % adjust face indices
end
I tried to convert the for loop to a matrix operation but it exceeded the memory limit. Is there another way to speed this up?
0 件のコメント
採用された回答
Walter Roberson
2017 年 11 月 27 日
[~, binnum] = histc(faces, [pt_indices, inf]);
faces = faces - binnum;
その他の回答 (0 件)
参考
カテゴリ
Help Center および 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!