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 Kommentare

jnaumann
jnaumann am 14 Nov. 2013
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.
ala alemaryeen
ala alemaryeen am 14 Nov. 2013
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,

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 14 Nov. 2013

0 Stimmen

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

Weitere Antworten (0)

Kategorien

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by