How to use sparse matrix without any problem with MAXSIZE ?
이전 댓글 표시
I want to use mRMR algorithm and a part of code is using mutualinfoDis function that it's code is:
% feature-selection-mRMR
% Created by Jiahong K. Chen
% Input: x, y two vector of discrete data
% Output: I(x,y) = mutual information of x and y
function mi = mutualInfoDis(x, y)
n = length(x);
% reshape x and y into column vector
x = x(:);
y = y(:);
% shift x and y to 1:max([x;y])
lo = min( [ x; y ] );
x = x - lo + 1;
y = y - lo + 1;
up = max( [ x; y ] );
% negative Joint entropy
idx = (1:n);
tabX = sparse(idx, x, 1, n, up, n);
tabY = sparse(idx, y, 1, n, up, n);
Pxy = nonzeros(tabX'*tabY) / n;
negHxy = Pxy' * log(Pxy);
% negative Entropy
Px = mean(tabX);
Py = mean(tabY);
negHx = Px * log(Px)';
negHy = Py * log(Py)';
% Mutual information
mi = negHxy - negHx - negHy;
%mi = mi/log(2);
end
but this error is showed:
Error using sparse
Sparse matrix sizes must be non-negative integers less than MAXSIZE as defined by COMPUTER. Use HELP COMPUTER for more
details.
Error in mutualInfoDis (line 23)
tabX = sparse(idx, x, 1, n, up, n);
I obtained the maxsize of the MATLAB program installed on my computer that is
>> [str,maxsize]=computer
str =
PCWIN64
maxsize =
2.8147e+14
But I don't know how to solve this error,I changes n to this value or less than maxsize but still, the program has problem with using sparse, I'll be vary grateful to have your opinions.Thank You
댓글 수: 4
Matt J
2020년 4월 13일
What is the value of "up"?
Steven Lord
2020년 4월 13일
The values of n and up would be useful to know to determine if what you're trying to do is possible.
phdcomputer Eng
2020년 4월 13일
phdcomputer Eng
2020년 4월 13일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!