Merging two columns into one
8 views (last 30 days)
Show older comments
Hello everyone,
Hope you are doing fine.
I have a questions, I have two columns lets call them E and F, they're of the same type (double) the size of E is 317760 by 1 and the size of F is 271776 by 1.
I know I can use vertcat to have them in one column E after F or vice versa but that's not what I want to do.
I have two other columns called Location1 and Location2, these columns are of the same size as E and F. What I want to do is merge E and F regarding location 1 and location 2.
For example: E = [10 20 30], F = [70 80 60] Location1 = [2 4 6] , Location 2= [ 1 3 5] I want my result to be E(according to location1) together with F(Location2) so: C = [70 10 80 20 60 30]. Even though Location1 and 2 here are alternating my actual data don't alternate.
If any clarification is needed please let me know,
Any ideas on how to do this would be great!
Thank You.
0 Comments
Accepted Answer
michio
on 21 Sep 2017
E = [10 20 30];
F = [70 80 60];
Location1= [2 4 6];
Location2= [1 3 5];
EF = zeros(1,6);
EF(Location1) = E;
EF(Location2) = F;
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!