How to use sparse matrix without any problem with MAXSIZE ?

1 view (last 30 days)
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 Comments
phdcomputer Eng
phdcomputer Eng on 13 Apr 2020
@Steven Lord n=62 and up=1.4876e+04 how to solve the error of these lines
tabX = sparse(idx, x, 1, n, up);
tabY = sparse(idx, y, 1, n, up);

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!