Question: Write a function called maxmin_rows that takes a matrix as input argument (the function does not have to check the format of the input) and

Write a function called maxmin_rows that takes a matrix as input argument (the function does not have to check the format of the input) and returns two vectors as output arguments. The elements of the first vector are the maximums of elements of the rows of the input matrix. The elements of the second output vector are the minimums of elements of the rows of the input matrix. Note that the built-in MATLAB functions max and min return the maximum and minimum of the columns. Consider the following run,

>> x = [1 2 3; -1 0 6]

x =

1 2 3

-1 0 6

>> max(x)

ans =

1 2 6

>> min(x)

ans =

-1 0 3

>> [maxi mini] = maxmin_rows(x)

maxi =

3 6

mini =

1 -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!