필터 지우기
필터 지우기

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?

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 27일
[~, binnum] = histc(faces, [pt_indices, inf]);
faces = faces - binnum;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by