Effacer les filtres
Effacer les filtres

Merging two columns into one

4 vues (au cours des 30 derniers jours)
John Doe
John Doe le 21 Sep 2017
Commenté : John Doe le 22 Sep 2017
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.

Réponse acceptée

michio
michio le 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;
  1 commentaire
John Doe
John Doe le 22 Sep 2017
Thank You^^

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by