building a square matrix out of a vector

조회 수: 4 (최근 30일)
Hossein
Hossein 2014년 3월 8일
댓글: Hossein 2014년 3월 8일
Hi everyone,
im trying to build a [n X n] matrix from a [1 n*n] vector. can anybody give me a simple code?

채택된 답변

Mischa Kim
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 CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by