sort cell arrays based on mean value
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Amir Hosein Shokouhy
am 17 Jul. 2021
Beantwortet: Star Strider
am 17 Jul. 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 Kommentare
Akzeptierte Antwort
Star Strider
am 17 Jul. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!