sort cell array in a struct

4 vues (au cours des 30 derniers jours)
Chiara Scarpellini
Chiara Scarpellini le 7 Août 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.
  6 commentaires
Walter Roberson
Walter Roberson le 7 Août 2021
Modifié(e) : Walter Roberson le 8 Août 2021
[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
Chiara Scarpellini le 7 Août 2021
it works! huge thank you!

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Août 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);

Plus de réponses (0)

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!

Translated by