Question: d) Write a function named gm = myGeomean2(x, id) that accepts a matrix X of arbitrary size. If id = 1, gm is a row

d) Write a function named gm = myGeomean2(x, id) that accepts a matrix X of arbitrary size. If id = 1, gm is a row vector containing the geometric mean of each column of X. If id = 2, gm is a column vector containing the geometric mean of each row of X. gm = -1 if X contains any non-positive values. Verify your function on one matrix of your choice (the numbers of rows and columns should be greater than or equal to 5, and all elements of the matrix should be positive) with two different values of id = 1, 2, and print your results and the results returned by the built-in MATLAB function geomean (X, dim), with dim =1, 2. Read this document for more details. Note: you are not allowed to call the built-in MATLAB function geomean in myGeomean2, but you can call myGeomean. Verify your function on a matrix containing negative elements, and print the result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
