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
(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.
Step by Step Solution
3.47 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
To implement your own version of the max function in MATLAB you can follow these steps Define a func...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