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 (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 resultStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started