Rearranging values in a matrix

조회 수: 1 (최근 30일)
Gregory Olive
Gregory Olive 2018년 3월 11일
댓글: Gregory Olive 2018년 3월 11일
I have a matrix that has 4 columns and I would like to rearrange it to have 5 columns so that the value in the second row first column becomes the value in the first row fifth column. So if the matrix was:
[1 2 3 4
5 1 2 3
4 5 1 2
3 4 5 1
2 3 4 5]
It would become:
[1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5]
Does anybody know how I could do this? Thanks in advance!

답변 (1개)

Von Duesenberg
Von Duesenberg 2018년 3월 11일
Suppose your initial matrix is called oldMat:
reshape(oldMat', [5, 4])'
  댓글 수: 3
Von Duesenberg
Von Duesenberg 2018년 3월 11일
Thanks for the tip.
Gregory Olive
Gregory Olive 2018년 3월 11일
Awesome thanks!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by