필터 지우기
필터 지우기

How transform a vector into a Matrix

조회 수: 391 (최근 30일)
So
So 2016년 5월 19일
편집: So 2016년 5월 19일
Hello, I am trying to transform a line vector of length x² to a matrix size x*x. For example,
Vector = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
and I want
Matrix = [ 1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16]
This is only an example, I am trying to write a function for any vector. Thank you.

채택된 답변

Stephen23
Stephen23 2016년 5월 19일
편집: Stephen23 2016년 5월 19일
Use reshape:
>> V = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16];
>> M = reshape(V,4,4)
M =
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
  댓글 수: 1
So
So 2016년 5월 19일
편집: So 2016년 5월 19일
Oh yeah i made a mistak.. thank you :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cartesian Coordinate System Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by