changing similar numbers in a raw
Mostra commenti meno recenti
Dear all,
I have a raw with repeated numbers. I want to change them to different onse exactly like the randperm.
X=[1 2 2 2 3 2 4 2 2 2];
i want to make it
X=[1 2 4 3 7 5 8 6 10 9];
many thanks
1 Commento
KALYAN ACHARJYA
il 3 Apr 2022
Modificato: KALYAN ACHARJYA
il 3 Apr 2022
X=[1 2 2 2 3 2 4 2 2 2];
Desired result? Any issue?
X=randperm(length(X))
Risposte (2)
nadia nadi
il 3 Apr 2022
0 voti
try this:
X=[1 2 2 2 3 2 4 2 2 2];
a=X(X==2);
b=randperm(length(a));
a=b;
X(X==2)=0;
X(X==0)=a
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!