Reference no: EM132206047
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 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