Merging three table data or array data in column wise in alternative sequence
Show older comments
I have three tables like mentioned below
Table A Table B Table C
0 A1 A2 A3 0 B1 B2 B3 0 C1 C2 C3
10 A1 A2 A3 10 B1 B2 B3 10 C1 C2 C3
20 A1 A2 A3 20 B1 B2 B3 20 C1 C2 C3
30 A1 A2 A3 30 B1 B2 B3 30 C1 C2 C3
40 A1 A2 A3 40 B1 B2 B3 40 C1 C2 C3
Combined Table ABC in alternative way column wise
0 A1 B1 C1 A2 B2 C2 A3 B3 C3
10 A1 B1 C1 A2 B2 C2 A3 B3 C3
20 A1 B1 C1 A2 B2 C2 A3 B3 C3
30 A1 B1 C1 A2 B2 C2 A3 B3 C3
40 A1 B1 C1 A2 B2 C2 A3 B3 C3
i need to perform this process in loop to merge 400+ data column.
test1=array2table(hs_coeff');
test2=array2table(ms_coeff');
test3=array2table(ls_coeff');
testtable = table(test1.Var1,test2.Var1,test3.Var1);
the above is my code need to loop the testtable to 434 time to merger 434 column of each table test1, test2 and test3
i also tried with array itself like mentioned below
for i=1:434
testtable = [hs_coeff(i,:);ms_coeff(i,:);ls_coeff(i,:)];
end
4 Comments
Mohammed Hablullah
on 10 Dec 2019
Mohammed Hablullah
on 10 Dec 2019
Edited: Mohammed Hablullah
on 11 Dec 2019
This line should be throwing an error since your table's variable names are the same between the tables. But you wrote that you're getting a result. So, either the variable names are different from what you reported or you're changing them somewhere. We can't concatenate tables with duplicate headers.
testtable1(:,i) = [test1(:,i); test2(:,i); test3(:,i)];
Answers (0)
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!