How to concatenate two matrices

3 vues (au cours des 30 derniers jours)
Sharon
Sharon le 23 Mar 2012
I need to concatenate two matrices
x=[ 1 2 3 4]
y=[5 6 7 8]
such that I get
z=[1 5 2 6 3 7 4 8]
  2 commentaires
Oleg Komarov
Oleg Komarov le 23 Mar 2012
Have you tried looking in the documentation for "concatenate"?
Sharon
Sharon le 23 Mar 2012
yes cat(2,x,y) gives me
ans=
1 2 3 4 5 6 7 8 and not
1 5 2 6 3 7 4 8

Connectez-vous pour commenter.

Réponse acceptée

Honglei Chen
Honglei Chen le 23 Mar 2012
z = [x;y];
z = z(:).'
  1 commentaire
Sharon
Sharon le 23 Mar 2012
thanks..

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by