Hi, i need to form a matrix using this vector a=[ 1 2 3 5 6 7 8 9 2 1 2], the matrix elements be A=[1 2 3 4 5 6; 7 8 9 2 1 2]
i used reshape command but it doesn't give me the sequence i want.

2 Commenti

Are you using the matrix you have given? There are only 11 elements in it. If it had 12 as I imagine it should (probably a typo).
reshape(a,2,6)
Should you give you what you want.
i am sorry it contains 12 elements. i used this command it gives A=[1 3 6 8 2 2; 2 5 7 9 1 0] i don't need this format i need the first 6 elements in the first row, and the other elements in the second row. Thanks,

Accedi per commentare.

 Risposta accettata

a=[ 1 2 3 4 5 6 7 8 9 2 1 2];
reshape(a,6,2)'

Più risposte (0)

Categorie

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by