reference elements in a matrix based on values in a vector
1 次查看(过去 30 天)
显示 更早的评论
I have the 1x9 vector [5 3 2 6 7 26 4 33 3]
I want to obtain the matrix [5 3 2; 6 7 26; 4 33 3] using completely vectorized code. How can this be done?
As a start, I have vectorized code to build the 3x3 matrix [ 1 2 3; 4 5 6; 7 8 9], so that the values are the vector columns, but I don't know how to do the vectorized referencing.
Thanks
0 个评论
采纳的回答
Azzi Abdelmalek
2014-2-23
编辑:Azzi Abdelmalek
2014-2-23
A= [5 3 2 6 7 26 4 33 3]
out= reshape(A,3,[])'
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 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!