Removing element of array at random
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ndugatuda Maxwell
am 31 Dez. 2021
Kommentiert: Ndugatuda Maxwell
am 31 Dez. 2021
I have a 200 x 1 matrix of random numbers and I want to remove 10 numbers from the array at random.
Here is sample data i used:
a = 0; %mean
b = 1; %standard deviation
random_num = b*randn(200,1)+a; %generates random numbers
How can I remove, at random 10 numbers from the random_num variable?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 31 Dez. 2021
a = 0;
b = 1;
rn = b*randn(200,1)+1;
ix = randperm(200,10) % indices of elements to remove
rn(ix) = []; % remove elements
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!