Effacer les filtres
Effacer les filtres

How to rearrange String Data within table relative to one Column of Data.

3 vues (au cours des 30 derniers jours)
Sai Gudlur
Sai Gudlur le 7 Mai 2024
Commenté : Voss le 7 Mai 2024
Hello,
I have a table with 80X10. The first Variable (Var 1) has text Data, Variable 8 (Relavent Data), Variable 9 (parameter List), Variable 10 (GPP_Names). Var1 to Var8 Imported from File A and Var 9, Var10 (Parameter_List & Gpp_Names) Imported from another.
Both Contatinated (horzcat) and put together in one table Common_Data_1. As in the attached picture.
Var 1 & Var 9 (Parameter_List) are exactly same text. But I am unable to arrange it to match each other.
Var9 (Parameter_List) & Var 10 (Gpp_Names) are alligned Perfectly.
I would like to extract Var 1,Var8, Parameter_List,GPP_Names data that perfectly aligned.
1) Should I match the text pattern before Concatinating them into one Table?
2) How could I use sortrows or rowfun or other functions to arrange this data?
Any help or suggestion would be of great help.
Thanks
Sai

Réponse acceptée

Voss
Voss le 7 Mai 2024
"Should I match the text pattern before Concatinating them into one Table?"
You can do it that way, but since I don't know much about what the tables were before they were combined, I'll provide a way to start with your existing combined table Common_Data_1 and reorder Parameter_List and GPP_Names together such that Parameter_List is the same as Var1:
[~,idx] = ismember(Common_Data_1.(1),Common_Data_1.(9));
Common_Data_1(:,[9 10]) = Common_Data_1(idx,[9 10]);
  2 commentaires
Sai Gudlur
Sai Gudlur le 7 Mai 2024
Thanks a lot. it is straight forward could figure it. Thank you again
Voss
Voss le 7 Mai 2024
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by