Question: Selecting random elements from an array. Assign selectedValues with numberSelected randomly selected elements from row array dataSet. Duplicate selections are acceptable. Hint: Use the randi

Selecting random elements from an array.
Assign selectedValues with numberSelected randomly selected elements from row array dataSet. Duplicate selections are acceptable.
Hint: Use the randi function and an indexing array.
Ex: If numberSelected is 3 and dataSet is 74,13,1,51,6, then selectedValues might return 1,74,13.
Note: Successive "Runs" with the same arguments may return different results due to the random number generation. The "Submit for
Assessment" tests are configured to produce the same random numbers.
Function ?
1 function selectedValues = selectRandom (dataSet, numberSelected )
3% selectRandom: Return numsel elements of input array data selected at
4% Inputs: data - selections are acceptable.
5% numsel - number input data values
6,%
7,% Outputs: selected - a randomly selected elements to return
9% Choose randoct - array of randomly selected data values
10% Choose randomly selected elements for output.
end
Code to call your function ?
1 selectRandom ([74,13,1,51,6],3)C Reset
 Selecting random elements from an array. Assign selectedValues with numberSelected randomly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!