I want to calculate the solutions of some huge linear system of equations by backslash function and save the norm of solutions in a excel file, and I don't want Matlab stopped when for some cases it has "Out of Memory". Please let me know how can I solve this problem

Réponses (1)

Walter Roberson
Walter Roberson le 13 Jan 2023

0 votes

You could add more ram.
In some cases you might be able to use sparse matrices.
In some cases you might be able to use tall() arrays.

4 commentaires

Ali Shahmoradi
Ali Shahmoradi le 13 Jan 2023
Déplacé(e) : Steven Lord le 13 Jan 2023
But I want to write 'out of memory' in my excel file and pass this iteration
Christine Tobler
Christine Tobler le 13 Jan 2023
Déplacé(e) : Steven Lord le 13 Jan 2023
You can wrap the call to backslash in a try/catch statement, and then in the "catch" say what you want to do if an error was thrown.
For example:
for ii=1:10
try
x{ii} = A{ii} \ b{ii};
catch ME
x{ii} = "Error occured";
end
end
If there is an out-of-memory error, x{ii} is just filled with that string instead of the solution of linear system, but the computation will continue.
Walter Roberson
Walter Roberson le 13 Jan 2023
Huh, I did not think it was possible to catch out-of-memory, but testing I see that it is in at least some cases.
Ali Shahmoradi
Ali Shahmoradi le 14 Jan 2023
Thanks, It worked

Connectez-vous pour commenter.

Catégories

En savoir plus sur Parallel Computing Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by