interchange positions in a vector
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Maria Lancheros Vega
le 14 Nov 2020
Réponse apportée : Ameer Hamza
le 14 Nov 2020
I have a vector let's say y = [1 2 3 4] and I want my next output to be y = [2 3 4 1] and then y = [3 4 1 2].
how can I do that without a for?
0 commentaires
Réponse acceptée
Ameer Hamza
le 14 Nov 2020
You can use circshift
y = [1 2 3 4];
y1 = circshift(y, -1);
y2 = circshift(y, -2);
Result
>> y1
y1 =
2 3 4 1
>> y2
y2 =
3 4 1 2
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!