# finding the 10 biggest values in a cell array

2 vues (au cours des 30 derniers jours)
AA le 5 Nov 2017
I have a cell array 10x10 that consists of of several matrices (1000x1) with integers. I want to find the 10 biggest integers in that cell array and the corresponding column and rows in the cell array and the corresponding row in the matrix.
thanks
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (2)

mizuki le 6 Nov 2017
Use cell2mat and find would be the easiest way. If you do not want to convert the cell array into the double array, use cellfun .
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Walter Roberson le 6 Nov 2017
data_matrix = horzcat(YourCellArray{:});
[sorted_matrix, sort_idx] = sort(data_matrix, 'descend');
best_10_vals = sorted_matrix(1:10);
best_10_idx = sort_idx(1:10);
[orig_row_in_cell, cellnum] = ind2sub(size(data_matrix), best_10_idx);
[orig_cell_row, orig_cell_col] = ind2sub(size(YourCellArray), cellnum);
Now,
YourCellMatrix{orig_cell_row{K}, orig_cell_col{K})(orig_row_in_cell(K)) == best_10_vals(K)
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Text Data Preparation 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!

Translated by