Save results to disk in a loop/RAM Memory problem

Hello,
I am having problems with the limit of RAM memory. In my application, I have a loop like the following:
%% 1. Data obtaining
n_loops=1000;
all_results = zeros(dim1, dim2, n_loops)
for i=1:n_loops
%result_of_one_loop = get_result_command;
all_results(:,:,i) = result_of_one_loop;
end
%% 2. Post-processing
%Post-procesing code here.
This code runs out the RAM. Is there any option to solve this problem? Maybe saving into the disk memory the results file, increasing the size in each loop (but not overwriting)? Thank you so much for your help.

2 comentarios

Jan
Jan el 26 de En. de 2023
This piece of code is too simplified, to explain the source of the problem. If the pre-allocation zeros(dim1, dim2, n_loops) is working successfully, filling the memory is no reason for further allocations.
Please postr some code, which reproduces the problm and pos a copy opf the complete error message. This will show us, which line is failing.
Thank you for your answer. I could reduce the dimensions of the matrix I was using and now it works.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Preguntada:

el 26 de En. de 2023

Editada:

el 3 de Feb. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by