sort cell array in a struct
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Chiara Scarpellini
el 7 de Ag. de 2021
Respondida: Walter Roberson
el 8 de Ag. de 2021
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/705277/image.png)
6 comentarios
Walter Roberson
el 7 de Ag. de 2021
Editada: Walter Roberson
el 8 de Ag. de 2021
[Name_Code.Codes, Cidx] = cellfun(@sort,Name_Code.Codes,"UniformOutput",false);
Name_Code.Discharge = cellfun(@(d,idx)d(idx), Name_Code.Discharge, Cidx);
Respuesta aceptada
Walter Roberson
el 8 de Ag. de 2021
(Moving down from comment)
[Name_Code.Codes, Cidx] = cellfun(@sort,Name_Code.Codes,"UniformOutput",false);
Name_Code.Discharge = cellfun(@(d,idx)d(idx), Name_Code.Discharge, Cidx);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!