How to replace values in a very large array
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jonathan Weber
el 3 de Ag. de 2022
Comentada: Jonathan Weber
el 4 de Ag. de 2022
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 comentarios
Respuesta aceptada
Mohammad Sami
el 4 de Ag. de 2022
xx=find(tdcRelTime < 1.5e10);
idx_Laser(ismember(idx_Laser,xx)) = 0;
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!