How to replace values in a very large array
이전 댓글 표시
Hi
I have an array idx_Laser which is very large (~1 billion values). Whenever a certain condition is fulfilled for another array tdcRelTime I want to replace the values in my idx_Laser array.
The trivial solution would probably be:
for xx = 1:length(tdcRelTime)
if tdcRelTime(xx) < 1.5e10
idx_Laser(idx_Laser==xx) = 0;
end
end
However, as both arrays are quite big, this takes extremely long.
Is there a solution for that problem that is computionally more efficient?
I thought about iterating only through a part of the idx_Laser array, as this is sorted by the size of the values, but I couldnt come up with a good solution.
댓글 수: 3
dpb
2022년 8월 3일
Can you hold the arrays in memory?
If that is the case, it's already vectorized for you --
ix=(tdcRelTime < 1.5e10);
idx_Laser(ix) = 0;
If the arrays are being held in virtual memory and you're paging to address them in the above code, that will be slow.
Jonathan Weber
2022년 8월 4일
Jonathan Weber
2022년 8월 4일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!