How to move values of matrix for 1 out of two rows?

조회 수: 1 (최근 30일)
MICHEL PHILIPE LIOUSSIS
MICHEL PHILIPE LIOUSSIS 2020년 1월 25일
댓글: Stephen23 2020년 1월 25일
Hello, I would like to move to values of a matrix to the next column every two rows. For example:
from 1 0 5 0 to 1 0 5 0
2 0 6 0 0 2 0 6
3 0 7 0 3 0 7 0
4 0 8 0 0 4 0 8
Thanks!

답변 (1개)

Stephen23
Stephen23 2020년 1월 25일
>> M = [1,0,5,0;2,0,6,0;3,0,7,0;4,0,8,0]
M =
1 0 5 0
2 0 6 0
3 0 7 0
4 0 8 0
>> M(2:2:end,:) = circshift(M(2:2:end,:),1,2)
M =
1 0 5 0
0 2 0 6
3 0 7 0
0 4 0 8
  댓글 수: 2
Stephen23
Stephen23 2020년 1월 25일
@MICHEL PHILIPE LIOUSSIS: I hope it helped. Please remember to accept my answer if it was useful!

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

카테고리

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