Reshape to column vector

조회 수: 2 (최근 30일)
Hingure Kadurugamuwa
Hingure Kadurugamuwa 2021년 10월 9일
댓글: Star Strider 2021년 10월 9일
I have
a =
1 2 3 4
5 6 7 8
9 10 11 12
I need to covert it to a column vector keeping the input order as follows,
b =
1
2
3
4
.
.
12
But when you use reshape funtion
b = [reshape(a,[12,1])]
b =
1
5
9
2
6
10
3
7
11
4
8
12
Can anyone help me on this?

답변 (1개)

Star Strider
Star Strider 2021년 10월 9일
Transpose ‘a’ before calling reshape
a = [1 2 3 4
5 6 7 8
9 10 11 12];
b = reshape(a.',[],1)
b = 12×1
1 2 3 4 5 6 7 8 9 10
.
  댓글 수: 2
Hingure Kadurugamuwa
Hingure Kadurugamuwa 2021년 10월 9일
Thanks a lot Star Strider
It worked
Star Strider
Star Strider 2021년 10월 9일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by