Find the indicies of the top 250 values of a Matrix
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I performed a spearman correlation analysis that produced a Rho variable. The size of the Rho variable is:
sizeRho = size(Rho) = [983, 27471]
Now, I am trying to find the the indicies for the top 250 values of Rho.
Here is some of what I have tried:
sizeRho = size (Rho);
top = maxk(Rho,250);
[B,I] = maxk(Rho,250, 'ComparisonMethod', 'abs');
[top, ixt, jxt] = prctile(Rho, [90])
top = prctile(Rho, [99])
largest_vals = maxk(Rho(:), 250);
[largest_vals, indicies_t] = maxk(Rho(:), 250);
Any help and/or advice would be greatly appreciated. Thank you.
4 commentaires
Torsten
le 5 Avr 2023
Why ? maxk returns a matrix whose columns contain the k largest elements of each column of A.
Thus the matrix has dimension 250x27471.
Réponse acceptée
the cyclist
le 5 Avr 2023
Modifié(e) : the cyclist
le 5 Avr 2023
[Sorry if you saw the incorrect solution I posted and then deleted.]
If you want the max values and indices for the matrix overall (rather than each column), you need this syntax:
[B,I] = maxk(Rho(:),250, 'ComparisonMethod', 'abs');
Note the use of Rho(:) as an input, rather than just Rho.
The output I has the linear indices into M.
For example
M = magic(4)
[B,I] = maxk(M(:),3, 'ComparisonMethod', 'abs')
Plus de réponses (1)
Chunru
le 5 Avr 2023
Not very clear on what you are asking. Here is a guess.
Rho = rand(5, 6) % small matrix for illustration
[B, I] = maxk(Rho(:), 7, 'ComparisonMethod', 'abs') % top 7 of all Rho (not columnwise)
[row, col] = ind2sub(size(Rho), I);
[row col]
Voir également
Catégories
En savoir plus sur Descriptive Statistics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!