How can I convert an array to a matrix?
216 次查看(过去 30 天)
显示 更早的评论
I have an array like B=[2 3 1 5 2 8 1 7 9 1 5 2 4 6 3 9 3 1 7 0 7 2 8 6].
I need this elements in a matrix called A like
A=
2 3 1 5 2 8 1 7
9 1 5 2 4 6 3 9
3 1 7 0 7 2 8 6
Please help...
0 个评论
采纳的回答
José-Luis
2013-1-29
B=[2 3 1 5 2 8 1 7 9 10 5 21 4 6 3 9 3 1 7 0 7 2 8 6];
A = reshape(B,8,3)'
0 个评论
更多回答(2 个)
Andreas Goser
2013-1-29
In MATLAB all arrays are matrices... You may achieve what you need by using the RESHAPE command.
0 个评论
Martin
2013-1-29
As Jose mentioned the reshape function is a really good one. The help file on that one is really useful for explaining how it works.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!