Efficient ways to tackle memory problems while creating a symmetric matrix

조회 수: 1 (최근 30일)
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by