Borrar filtros
Borrar filtros

Merging two columns into one

4 visualizaciones (últimos 30 días)
John Doe
John Doe el 21 de Sept. de 2017
Comentada: John Doe el 22 de Sept. de 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.

Respuesta aceptada

michio
michio el 21 de Sept. de 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;

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by