How to use sparse matrix without any problem with MAXSIZE ?
Afficher commentaires plus anciens
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 commentaires
Matt J
le 13 Avr 2020
What is the value of "up"?
Steven Lord
le 13 Avr 2020
The values of n and up would be useful to know to determine if what you're trying to do is possible.
phdcomputer Eng
le 13 Avr 2020
phdcomputer Eng
le 13 Avr 2020
Réponses (0)
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!