HOW CAN CREATE A MATRIX FROM A SINGLE ROW?
1 次查看(过去 30 天)
显示 更早的评论
I have 12 elements distributed on a single row, i've to put them on a 3x4 matrix, how i do that?
0 个评论
采纳的回答
Arif Hoq
2022-3-13
use reshape function.
A=randi(100,1,12)
output=reshape(A,3,4)
1 个评论
John D'Errico
2022-3-13
With only the caveat that the solution offerd by @Arif Hoq puts the elements into the matrix going down the columns. If @simone zappalà wanted to put the elements going across rows from the original vector, then this subtle change would do the trick:
A = [99 27 87 54 85 99 10 14 94 9 80 42];
output=reshape(A,4,3).'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!