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

1 次查看(过去 30 天)
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

采纳的回答

Voss
Voss 2024-5-7
"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]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by