sort cell arrays based on mean value
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Amir Hosein Shokouhy
le 17 Juil 2021
Réponse apportée : Star Strider
le 17 Juil 2021
Hi,
I have a 1*8 cell variable. I wanna sort these cells based on their mean values.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/686978/image.png)
The mean valuse are as below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/686983/image.png)
Thanks,
Amir
0 commentaires
Réponse acceptée
Star Strider
le 17 Juil 2021
Try something like this —
c = mat2cell(rand(150,1), [10 20 30 40 50], 1) % Create Cell ARray
[cm,idx] = sort(cellfun(@mean, c)) % Calculate & Sort By Means
c_sorted = c(idx) % Sorted Cell Array
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices 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!