Question: Write a function extract_odds that takes an array of random integers (you can generate this with the Matlab command v = randi([0 50],[100, 1]); )

 Write a function extract_odds that takes an array of random integers

Write a function extract_odds that takes an array of random integers (you can generate this with the Matlab command v = randi([0 50],[100, 1]);) and returns only the elements of the array that are even, using an if...else statement.

8) Write a function extract_odds_or_evens that takes two inputs: an array of random integers like in (7) and a second parameter that is either the string odd or even. Use combinations of a for loop and up to two if...else statements to extract either the odd or even numbers based on the second parameter and return the result.

7) Write a function extract_odds that takes an array of random integers (you can generate this with the Matlab command v = randi(0 50],[100, 1))) and returns only the elements of the array that are even, using an if..else statement. 8) Write a function extract odds_or evens that takes two inputs: an array of random integers like in (7) and a second parameter that is either the string 'odd' or 'even'. Use combinations of a for loop and up to two if...else statements to extract either the odd or even numbers based on the second parameter and return the result

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!