필터 지우기
필터 지우기

Change a 3x100 double to a 300x1 double

조회 수: 2 (최근 30일)
Hollis Williams
Hollis Williams 2019년 3월 24일
편집: madhan ravi 2019년 3월 24일
I have a 3 x 100 double ie. 100 column vectors next to each other all with 3 rows, and I need to take each column vector and put them all on top of each other in one long 300 x 1 column vector, what would be the easiest way of doing this?
I appreciate there is help material on idexing matrices but I could not find anything which particularly explains how to do this.

채택된 답변

madhan ravi
madhan ravi 2019년 3월 24일
reshape(a.',[],1) % a is of size 3 X 100
  댓글 수: 2
Hollis Williams
Hollis Williams 2019년 3월 24일
That doesn't quite work as it seems to re-order the elements somehow. So if I have a matrix like
1 8 9
2 6 4
4 2 3
I need the new vector to be
1
2
4
8
6
2
9
4
3
At the moment with your suggestion you get the right size but it's like the elements get bunched together if they have the same size.
madhan ravi
madhan ravi 2019년 3월 24일
편집: madhan ravi 2019년 3월 24일
a = [ 1 8 9 ;...
2 6 4 ;...
4 2 3 ]
Result = reshape(a,[],1)
%or
Result = a(:)
Gives:
Result =
1
2
4
8
6
2
9
4
3

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by