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 个评论

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.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by