solving memory problem for this code

조회 수: 3 (최근 30일)
NA
NA 2019년 5월 19일
답변: Walter Roberson 2019년 5월 19일
I run this code for X that has size 42*12
if size(X,2)==1
M=0;
end
n = size(X, 1);
rank_X = rank(X);
for d = 1:(n-1)
newn = n - d;
indices_matrix = combnk(1:n, newn);
Mset = 0; % for breaking the loop need to define initial value
for j = 1:size(indices_matrix, 1)
indices = indices_matrix(j, :);
X_minus_d = X(indices, :);
rank_X_minus_d = rank(X_minus_d);
if (rank_X_minus_d < rank_X)
dstar = d;
M = n - dstar;
Mset = 1;
break
end
end
if Mset == 1 % breaking from first loop
break
end
end
And gives this error
Out of memory.
How can I fix this problem?

답변 (1개)

Walter Roberson
Walter Roberson 2019년 5월 19일
You cannot fix that. combnk(1:n,newn) takes all combinations of 1:n, newn at a time, where your n is 42, and newn is 41 down to 1. The maximum number of combinations is 538257874440 when newn = 21 . For that, each entry would be length 21 doubles, 8 bytes per double, so you would need 538257874440 * 21 * 8 = 90427322905920 bytes, which is about 83 terabytes of memory. Do you have that much RAM in your system?:

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by