Efficient ways to tackle memory problems while creating a symmetric matrix

1 visualizzazione (ultimi 30 giorni)
I have written a function which gives a required symmetric matrix with real values. The input variable to the function is indicative of the size of the matrix. I am running into memory issues when this size is very large(like when n=128, for my computer), even while initializing the array itself. The code looks something like this,
function C = circcont(n)
deltan = n;
xs = (-deltan:1:deltan)';
ys = (-deltan:1:deltan)';
xlength = length(xs);
ylength = length(ys);
Cu = zeros(ylength*xlength,ylength*xlength);
%..............................
% Manipulation of the Cu matrix
%..............................
C = Cu+Cu'-diag(diag(Cu));
end
The error I am receiving is "Error using zeros Requested 66049x66049 (32.5GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive."
I know that the main constraint is my computer memory. But is there a way I can make use of the property of symmetry of the matrix to store the values and thus make an efficient usage of the memory. Thanks.

Risposte (0)

Categorie

Scopri di più su Operators and Elementary Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by