swiching elements of same vector
Mostra commenti meno recenti
hi everybody, i have vector
X=[ 20; 0; 0;0; 100; 0;0;0;50];
i would like to have
X=[0;0;0;0;20;0;0;0;100];
so that each number take the next number case
Risposta accettata
Più risposte (1)
Jos (10584)
il 6 Apr 2016
Modificato: Jos (10584)
il 6 Apr 2016
Easy:
X = [20 0 0 0 100 0 0 50 0]'
[i,~,v] = find(X)
X(i) = [0 ; v(1:end-1)]
1 Commento
jean claude
il 6 Apr 2016
Modificato: jean claude
il 6 Apr 2016
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!