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 and dataSet is then selectedValues might return
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
function selectedValues selectRandom dataSet numberSelected
selectRandom: Return numsel elements of input array data selected at
Inputs: data selections are acceptable.
numsel number input data values
Outputs: selected a randomly selected elements to return
Choose randoct array of randomly selected data values
Choose randomly selected elements for output.
end
Code to call your function
selectRandom Reset
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
