Merging two columns into one
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
michio
2017-9-21
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;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!