building a square matrix out of a vector
15 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
im trying to build a [n X n] matrix from a [1 n*n] vector. can anybody give me a simple code?
0 个评论
采纳的回答
Mischa Kim
2014-3-8
编辑:Mischa Kim
2014-3-8
Hossein, use reshape:
A = 1:4*4;
n = sqrt(length(A)); % if A is indeed an n*n vector
B = reshape(A,n,n)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!