Get the max (and its index) of a row in MATLAB

Given a M x N matrix, getting a column vector of the max of each row and another with the index of such maximum is done as follows:

h = sigmoid(a3);
[p, i] = max(h, [], 2);

p -> column vector of the maximum values.
i -> column vector of the maximum value indexes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s