(MATLAB) There's built-in max function, for determining themaximum of a vector of elements. The function is more...
Question:
(MATLAB) There's built-in max function, for determining themaximum of a vector of elements. The function is more general,including the following two features.
In addition to returning the value of the maximum, it canproduce a second output argument that is the index ofwhere that maximum occurred. The calling syntax is
[Y I] = max(X);
where Y is the actual maximum and I is the index at which itoccurs. In the special case where there is a tie for the maximum,the index will be that of the first occurrence.
While the standard behavior applies on row vectors and columnvectors, the max(X) function has a slightly different behavior whenX is a matrix. It computes the maximum value and occurring index ona column-by-column basis. For example, when run on the followingmatrix
5 3 11
3 9 3
8 9 8
12 2 10
The first output argument is the vector of column-maximums
12 9 11
and the second output is the corresponding vector of indices
Your goal for this problem is to write your own version of thisfunction titled myMax. You are to ensure that it works preciselylike the official max function on both one-dimensional vectors andtwo-dimensional arrays
4 2 1.
Intermediate Microeconomics and Its Application
ISBN: 978-0324599107
11th edition
Authors: walter nicholson, christopher snyder