Concatenate/ Merge two HEX Cell Array
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
tinkyminky93
el 3 de Jun. de 2022
Editada: VINAYAK LUHA
el 3 de Jun. de 2022
Hello,
I have a two cell array which are 3x1 and 2x1. I want to merge them and want to see as 5x1. How can I do it? When I use horzcat, It says dimensions are not consistent. Thank you.
{'01'} {'04'} {'01'}
{'02'} {'05'} ----> {'02'}
{'03'} {'03'}
{'04'}
{'05'}
0 comentarios
Respuesta aceptada
Rik
el 3 de Jun. de 2022
You need to use vertcat instead, or use the semicolon.
a={'01';'02';'03'}
b={'04';'05'}
c=[a;b]
vertcat(a,b)
0 comentarios
Más respuestas (1)
VINAYAK LUHA
el 3 de Jun. de 2022
Editada: VINAYAK LUHA
el 3 de Jun. de 2022
Hi,
The reason horzcat doesn't work here is because the number of rows in both arrays are different , so you can't place them side by side , like
1 4
2 5
3
additionally , you won't get 5 x1 cell array you are looking for ,hence concat vertically using vertcat(X,Y) or like [X;Y] . Hope this solves your problem
X={'01';'02';'03'}
Y={'04';'05'}
Z=[X;Y]
0 comentarios
Ver también
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!