How to change element position in matrix?

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

Réponse acceptée

Askic V
Askic V le 24 Jan 2023
Modifié(e) : Askic V le 24 Jan 2023
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
  1 commentaire
ASHA PON
ASHA PON le 24 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