How do I remove 9 random numbers from a shuffled array?

2 Ansichten (letzte 30 Tage)
Ryan Littlejohn
Ryan Littlejohn am 16 Nov. 2019
Beantwortet: Image Analyst am 16 Nov. 2019
Hi, i have an array of numbers from 3 to 35 and i have a function created to shuffle these numbers. Right now my program takes the numbers from 3:35 and shuffles them. My question is how do i remove 9 random numbers from this array of shuffled numbers. Thanks

Antworten (3)

KALYAN ACHARJYA
KALYAN ACHARJYA am 16 Nov. 2019
Bearbeitet: KALYAN ACHARJYA am 16 Nov. 2019
"My question is how do i remove 9 random numbers from this array of shuffled numbers"
shuffled_data=randi(35,[1 35]); % Just Example
shuffle_data(randi(length(shuffle_data),[1 9]))=[]
  2 Kommentare
Ryan Littlejohn
Ryan Littlejohn am 16 Nov. 2019
thanks, i made an error in my question, to correct myself and to clarify i wanted to just remove 9 values from my shuffled array they don't have to be randomized because theyre already shuffled.
KALYAN ACHARJYA
KALYAN ACHARJYA am 16 Nov. 2019
shuffle_data(1:9)=[]
or
shuffle_data(randi(27):randi(27)+9)=[]
or
shuffle_data(end-9:end)=[]

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 16 Nov. 2019
shuffled_data(ismember(shuffled_data, values_to_ignore)) = [];

Image Analyst
Image Analyst am 16 Nov. 2019
Since they’re already shuffled simply do vec = vec(10:end) % Remove 9 values

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!

Translated by