필터 지우기
필터 지우기

Rearrange matrix into single row

조회 수: 10 (최근 30일)
Lanceric Tse
Lanceric Tse 2018년 8월 10일
편집: Stephen23 2018년 8월 10일
Hey there, I have a matrix that looks like this
b=1 2 3 4
1 2 3 4
1 2 3 4
What do I have to do to arrange it into a single row vector[ 1 2 3 4 1 2 3 4 1 2 3 4]?

채택된 답변

Paul Shoemaker
Paul Shoemaker 2018년 8월 10일
reshape(b',1,numel(b)) % Note the transpose ('), this is important.
  댓글 수: 1
Stephen23
Stephen23 2018년 8월 10일
편집: Stephen23 2018년 8월 10일
This answer uses complex transpose. See James Tursa's answer for the correct solution for all cases.

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

추가 답변 (1개)

James Tursa
James Tursa 2018년 8월 10일
편집: James Tursa 2018년 8월 10일
result = reshape(b.',1,[]);
The transpose is needed to get the row values to line up in memory first before doing the reshape.

카테고리

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