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].

 Respuesta aceptada

Star Strider
Star Strider el 19 de Mzo. de 2022
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 comentarios

Mariam Ahmed Fathy
Mariam Ahmed Fathy el 19 de Mzo. de 2022
Thanks @Star Strider for your help :))
Star Strider
Star Strider el 19 de Mzo. de 2022
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Mzo. de 2022

Comentada:

el 19 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by