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 件のコメント

Jan
Jan 2023 年 1 月 26 日
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.
JORGE REVUELTA LOSADA
JORGE REVUELTA LOSADA 2023 年 2 月 3 日
Thank you for your answer. I could reduce the dimensions of the matrix I was using and now it works.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2021b

質問済み:

2023 年 1 月 26 日

編集済み:

2023 年 2 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by