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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!