Max 2d for Matlab

75 views
Skip to first unread message

Haifeng GONG

unread,
May 19, 2010, 6:10:49 PM5/19/10
to MathTools
function [Val, Ind1, Ind2]=max2d(Mat);
%--------------------------------------------------------------------------
% max2d function 2d maximum function. Return the maximum value
% and index in a 2d matrix.
% Input : - Matrix.
% Output : - Maximum value.
% - [I,J] index of maximum.
% Tested : Matlab 5.3
% By : Eran O. Ofek October 2000
% URL : http://wise-obs.tau.ac.il/~eran/matlab.html
%--------------------------------------------------------------------------

[V1,I1] = max(Mat);
[V2,I2] = max(V1);

Val = V2;
Ind1 = I1(I2); % I
Ind2 = I2; % J

--
You received this message because you are subscribed to the Google Groups "MathTools" group.
To post to this group, send email to math...@googlegroups.com.
To unsubscribe from this group, send email to mathtools+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mathtools?hl=en.

Reply all
Reply to author
Forward
0 new messages