how to store elements from 2 arrays into another array?

14 vues (au cours des 30 derniers jours)
Hiba iqbal
Hiba iqbal le 4 Avr 2018
Commenté : Star Strider le 4 Avr 2018
ex: a=[1,2,3,4,5]; b=[6,7,8,9,10]; i want in a new array in 1st row as 1,6 2nd row 2,7 and so on. how do i do it in matlab?

Réponse acceptée

Star Strider
Star Strider le 4 Avr 2018
Probably the easiest way:
a = [1,2,3,4,5];
b = [6,7,8,9,10];
c = [a(:) b(:)]
c =
1 6
2 7
3 8
4 9
5 10
The (:) subscript reference creates column vectors. These are then concatenated horizontally to create ‘c’.
  2 commentaires
Hiba iqbal
Hiba iqbal le 4 Avr 2018
thanks
Star Strider
Star Strider le 4 Avr 2018
As always, my pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by