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 个评论

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,

请先登录,再进行评论。

 采纳的回答

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

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by