Question: Write a Matlab function called onlyoddprod.m which will take a vector of integers invest and return the product of only its odd positive entries as

 Write a Matlab function called onlyoddprod.m which will take a vector

Write a Matlab function called onlyoddprod.m which will take a vector of integers invest and return the product of only its odd positive entries as the value outfall. All negative entries, zero entries, and positive even entries will be ignored. If the vector contains no odd positive entries, then the function should simply return the value 1. You must use either a for loop or a while loop in you function to calculate the product. You are forbidden from using any other built-in Matlab functions as a part of your function. Function specifications and some sample function calls are given below. input parameter invest vector of integer values product of only odd positive entries input parameter invest output parameter outfall sample function calls onlyoddprod([1, 2, 3, 4, 5, 6, 7]) produces 105 onlyoddprod([-2, 3,0, 9, 4, -5]) produces 27 onlyoddprod([-8, -1,0, 2]) produces 1 onlyoddprod([2, 4, 6, 8, 10]) produces 1

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!