Concatenating 2 arrays without changing the dimension
Mostrar comentarios más antiguos
I want to concatenate 2 arrays of same dimension. And I want to add a blank space in between. When I use ' ', the dimension changes to nx2 while I want that the dimension should remain as nx1. Is there any way out to do this? Any help is welcome !!!!
E.g.: 2 arrays are of dimension n x 1. I want to concatenate them with a blank space. And, after that also I want that the dimension should be n x 1 and not n x 2.
Thanks again !!!!
4 comentarios
Jan
el 18 de Jun. de 2012
Please give a real example. Are you talking about cell strings?
Swasti Khuntia
el 18 de Jun. de 2012
Jan
el 18 de Jun. de 2012
Please, Swasti, give an explicite example. E.g.
Input:
C1 = {'26-Jun-2993'; '23-Dec-1998'}
C2 = {'17:23:45', '18:10:17'}
Output:
C3 = {'26-Jun-2993 17:23:45'; '23-Dec-1998 18:10:17'}
???
There are several possible types of "an array containing date and time".
Swasti Khuntia
el 18 de Jun. de 2012
Respuesta aceptada
Más respuestas (1)
Wayne King
el 18 de Jun. de 2012
x = randn(10,1);
y = randn(10,1);
z = [x ;y];
or
z = cat(1,x,y);
5 comentarios
Swasti Khuntia
el 18 de Jun. de 2012
Wayne King
el 18 de Jun. de 2012
I'm not sure I understand. How can you concatenate two arrays of dimension Nx1 into a single column and have the resulting dimension still Nx1? The dimension has to be 2*Nx1 if you don't want them to be Nx2
Swasti Khuntia
el 18 de Jun. de 2012
Wayne King
el 18 de Jun. de 2012
Then why is my answer not correct? What do you mean concatenate horizontally? Do you mean a row vector? Then just transpose the result.
Swasti Khuntia
el 18 de Jun. de 2012
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!