Question: As discussed in the class, the built - in MATLAB function randi can be used to generate an array of random integers with a specified

As discussed in the class, the built-in MATLAB function randi can be used to generate an array of
random integers with a specified range. For this question, create a vector vec that stores 20 random
integers generated by the randi function, each in the range from -20 to 50. Then do each of the following
tasks with only a SINGLE MATLAB statement: (Note: any conditional statements (if-else statement, for
and while loops) are NOT allowed to use in this question.).
a. Create a variable new_vec that stores all of the numbers that are multiplies of 4 from the vector
vec.(Hint: Consider the property of division and use help elfun to look for the proper
instruction)
b. Create a new array that contains only the positive integers from a)
c. Calculate the average in the array created in a) without using the mean function

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!