I have an array M
M = [1 2 3 4 ; -1 -2 -3 -4 ; 1 2 3 4 ; -1 -2 -3 -4]
I want to shuffle the rows of (M) from [1 2 3 4] to [1 3 4 2] and shuffle the columns of (M) from [1 2 3 4] to [3 2 4 1].

 채택된 답변

Star Strider
Star Strider 2022년 3월 19일

2 개 추천

Do exactly what you described —
M = [1 2 3 4 ; -1 -2 -3 -4 ; 1 2 3 4 ; -1 -2 -3 -4]
M = 4×4
1 2 3 4 -1 -2 -3 -4 1 2 3 4 -1 -2 -3 -4
Ms = M([1 3 4 2],[3 2 4 1])
Ms = 4×4
3 2 4 1 3 2 4 1 -3 -2 -4 -1 -3 -2 -4 -1
.

댓글 수: 2

Mariam Ahmed Fathy
Mariam Ahmed Fathy 2022년 3월 19일
Thanks @Star Strider for your help :))
Star Strider
Star Strider 2022년 3월 19일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2022년 3월 19일

댓글:

2022년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by