How to create a matrix that returns max values in each column/row in a vector

I need to write a script which prompts the user to enter a matrix (of any dimension) that is capable of returning the maximum value in each column and row in a vector.

Answers (1)

How do you want these maxima arranged in your vector result? Here is one possibility. Let M be your matrix.
A = [max(M,1).,max(M,2)];
This will create a single column vector with the column maxima occurring first and the row maxima next. There are many other ways of arranging these maxima. You should state what way you had in mind.

Categories

Asked:

on 25 Oct 2017

Answered:

on 25 Oct 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!