sort cell array in a struct
显示 更早的评论
I need to sort the vector Codes and I need the values of vector Discharge to be ordinated according to it. I tried the function sortrows but in this case it doesn't work since in soe cases I'm not working with scalars.

6 个评论
Walter Roberson
2021-8-7
What does it mean to sort Codes when Codes contains a mix of scalars and vectors?
How should be code 0 in row 10 be sorted relative to the 0 that is in the second element of row 3?
Chiara Scarpellini
2021-8-7
Walter Roberson
2021-8-7
Use a for loop and the second output of sort.
Chiara Scarpellini
2021-8-7
Walter Roberson
2021-8-7
编辑:Walter Roberson
2021-8-8
[Name_Code.Codes, Cidx] = cellfun(@sort,Name_Code.Codes,"UniformOutput",false);
Name_Code.Discharge = cellfun(@(d,idx)d(idx), Name_Code.Discharge, Cidx);
Chiara Scarpellini
2021-8-7
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!