필터 지우기
필터 지우기

Reshape a vector to a matrix

조회 수: 74 (최근 30일)
Nicolas Guerrero Naranjo
Nicolas Guerrero Naranjo 2021년 8월 18일
댓글: darova 2021년 8월 21일
Hello, I have the following doubt imagining that I have the vector
x=[1 2 3 4 5 6 7 8 9 10]
how can I do to reorganize it as follows
A=[1 2 3 4 5
6 7 8 9 10]
Since as we know reshape organizes as follows.
A=[1 3 5 7 9
2 4 6 8 10]
Thank u so much in advance.
  댓글 수: 1
Star Strider
Star Strider 2021년 8월 18일
This seems to be homework.
In any event, just use the reshape function.
.

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

채택된 답변

Wan Ji
Wan Ji 2021년 8월 18일
편집: Wan Ji 2021년 8월 18일
Just use reshape and transpose it!
x=[1 2 3 4 5 6 7 8 9 10] ;
A = reshape(x, 5, 2)'
Then we get
A =
1 2 3 4 5
6 7 8 9 10
This skill will usually be used in practical matlab programming
  댓글 수: 5
Wan Ji
Wan Ji 2021년 8월 21일
thsnk you, darova!
darova
darova 2021년 8월 21일
my pleasure

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by