How to rearrange String Data within table relative to one Column of Data.
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Voss
on 7 May 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]);
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!