%% Return Linear Indices
% Create a matrix A and return the maximum value of each row in the matrix M. Use the 'linear' option to also return the linear indices I such that M = A(I).

A = [1 2 3; 4 5 6]
[M,I] = max(A,[],2,'linear')
maxvals = A(I)

% Copyright 2018 The MathWorks, Inc.