Combine two cell array of different dimension
Afficher commentaires plus anciens
I have a two cell array A = {1,2}, B={4;5;6}
I need the result as one single array C = { 1 2 4
5
6 }
How it can be done?
Thank you
1 commentaire
If your cell arrays only contain scalar values, why are you bothering with cell arrays instead of the much faster and easier to use plain matrices?
Furthermore, it's unclear what output you want. Note that:
C = { 1 2 4
5
6 }
is not valid matlab syntax.
Réponse acceptée
Plus de réponses (2)
Sabarinathan Vadivelu
le 7 Mai 2015
Modifié(e) : Sabarinathan Vadivelu
le 7 Mai 2015
Try this
A = {1,2};
B = {3, 5, 6};
C = horzcat(A, B)
ans =
C = {1 2 3 5 6}
3 commentaires
Gopalakrishnan venkatesan
le 7 Mai 2015
Modifié(e) : Gopalakrishnan venkatesan
le 7 Mai 2015
Sabarinathan Vadivelu
le 7 Mai 2015
You should transpose one vector and then concatenate it.
A = {1,2}, B={3;4;5}
vertcat([A]',B)
ans =
[1]
[2]
[3]
[4]
[5]
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!