sort cell arrays based on mean value
1 view (last 30 days)
Show older comments
Amir Hosein Shokouhy
on 17 Jul 2021
Answered: Star Strider
on 17 Jul 2021
Hi,
I have a 1*8 cell variable. I wanna sort these cells based on their mean values.
The mean valuse are as below:
Thanks,
Amir
0 Comments
Accepted Answer
Star Strider
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!