Randperm without number 1

1 visualizzazione (ultimi 30 giorni)
Mary Hemler
Mary Hemler il 14 Mag 2020
Modificato: Stephen23 il 14 Mag 2020
I am using randperm to select positions that will be changed. How can I change my code so that the number 1 (position 1) is not included?
N = 50;
N20 = .2*N;
r = randperm(N,N20); %positions that are about to be changed
for y=r
S20a(:,y)=2*round(rand(1)) - 1;
end

Risposta accettata

Stephen23
Stephen23 il 14 Mag 2020
Modificato: Stephen23 il 14 Mag 2020
r = 1+randperm(N-1,N20);

Più risposte (0)

Categorie

Scopri di più su Modeling in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by