convert vector to matrix

조회 수: 20 (최근 30일)
Maina Kerbrat
Maina Kerbrat 2018년 10월 31일
답변: Star Strider 2018년 10월 31일
Hi all, I would like to convert a vector
A = [1,2,3,4,5,6]
to
matrix like that:
B=
[1 2 3,
4 5 6]
I tried to use reshape and I don't have vec2mat function. Do you have an idea? thank you

채택된 답변

Star Strider
Star Strider 2018년 10월 31일
Try this:
A = [1,2,3,4,5,6];
B = reshape(A(:), 3, []).'
B =
1 2 3
4 5 6

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by