How to rearrange matrix columns?

4 vues (au cours des 30 derniers jours)
ASHA PON
ASHA PON le 25 Jan 2023
Commenté : ASHA PON le 25 Jan 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]

Réponse acceptée

Arif Hoq
Arif Hoq le 25 Jan 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
  1 commentaire
ASHA PON
ASHA PON le 25 Jan 2023
Thank you this is what i needed.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by