How to rearrange matrix columns?

4 visualizzazioni (ultimi 30 giorni)
ASHA PON
ASHA PON il 25 Gen 2023
Commentato: ASHA PON il 25 Gen 2023
I am having 7*7 matrix. Now i need to rearrange the matrix colums in such a way that last column of the matrix will be considered first column and first column as second, second column as third and so on.
Example:
A=[0 0 0 1 0 0 0
0 1 0 0 0 0 0
0 0 0 0 1 0 0
1 0 0 0 0 0 0
0 0 0 0 0 1 0
0 0 1 0 0 0 0
0 0 0 0 0 0 1]
Expected output:
Example:
B=[0 0 0 0 1 0 0
0 0 1 0 0 0 0
0 0 0 0 0 1 0
0 1 0 0 0 0 0
0 0 0 0 0 0 1
0 0 0 1 0 0 0
1 0 0 0 0 0 0]

Risposta accettata

Arif Hoq
Arif Hoq il 25 Gen 2023
A=[0 0 0 1 0 0 0
0 1 0 0 0 0 0
0 0 0 0 1 0 0
1 0 0 0 0 0 0
0 0 0 0 0 1 0
0 0 1 0 0 0 0
0 0 0 0 0 0 1];
B= circshift(A,1,2)
B = 7×7
0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by