how to convert 9*1 matrix to 3*3 matrix

조회 수: 7 (최근 30일)
sunitha
sunitha 2021년 2월 25일
편집: Stephen23 2021년 2월 25일
I have a matrix A=[1;2;3;4;5;6;7;8;9] .i.e 9*1 ,now i want to convert 3*3 format like [ 1 4 7; 2 5 8;3 6 9] and i want to add values 1 column . how can i write the code??
  댓글 수: 2
Stephen23
Stephen23 2021년 2월 25일
편집: Stephen23 2021년 2월 25일
A=[1;2;3;4;5;6;7;8;9]
A = 9×1
1 2 3 4 5 6 7 8 9
B = reshape(A,3,3) % removed transpose (thank you James Tursa)
B = 3×3
1 4 7 2 5 8 3 6 9
James Tursa
James Tursa 2021년 2월 25일
You don't need the .' operation.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by