building a square matrix out of a vector
15 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Mischa Kim
on 8 Mar 2014
Edited: Mischa Kim
on 8 Mar 2014
Hossein, use reshape:
A = 1:4*4;
n = sqrt(length(A)); % if A is indeed an n*n vector
B = reshape(A,n,n)
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!