How to change element position in matrix?

조회 수: 3 (최근 30일)
ASHA PON
ASHA PON 2023년 1월 24일
댓글: ASHA PON 2023년 1월 24일
I am having 7*1 matrix. Now i need to generate a output matrix whose first element will be second element of matrix A and first element of matrix A will be considered as last element in output matrix.
For example:
A=[1;1;0;0;1;0;1]
Expected output:
B=[1;0;0;1;0;1;1]

채택된 답변

Askic V
Askic V 2023년 1월 24일
편집: Askic V 2023년 1월 24일
Please use Matlab built in function called: circshift
for example:
A=[1;1;0;0;1;0;1]
A = 7×1
1 1 0 0 1 0 1
B = circshift(A, [-1, -1])
B = 7×1
1 0 0 1 0 1 1

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by