out of memory error

10 visualizaciones (últimos 30 días)
joseph Frank
joseph Frank el 31 de Jul. de 2011
I am facing a continuous out of memory error and I am wondering if these codes can be modified to avoid it:where RG,PC,and Acr are 6000x14771 matrices. The error pops when i=4792 so I am not far from reaching i=6000:
for i=2:size(PC,1)
for j=2:size(PC,2)
RG(i,j)=((PC(i,j)-PC(i-1,j))+(Acr(i,j)-Acr(i-1,j)))./PC(i-1,j);
end
end

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 31 de Jul. de 2011
Did you pre-allocate RG? The three matrices take about 2G bytes of memory. Do you need keep PC and Acr? If not, there might be a way to vectorize to get RG without for-loop.
>> 6000*14771*3*8
ans =
2.1270e+009
  1 comentario
joseph Frank
joseph Frank el 31 de Jul. de 2011
pre-allocating RG solved the problem and the program finished very quickly. Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by