MINN N-D Array Minimum. MINN(A) returns the minimum value found in the array A. [MN,Row,Col] = MINN(A) for 2-D A returns the minimum value MN as well as the row and column subscripts where the minimum appears. Row and Col are column vectors if multiple minimums appear in A. [MN,Idx] = MINN(A) returns the minimum value MN as well as the linear indices Idx of all elements in A that are equal to MN. To get the row, column, ..., subscripts associated with the linear indices use IND2SUB(size(A),Idx).
0001 function [mn,idx,col]=minn(A) 0002 %MINN N-D Array Minimum. 0003 % MINN(A) returns the minimum value found in the array A. 0004 % 0005 % [MN,Row,Col] = MINN(A) for 2-D A returns the minimum value MN as well as 0006 % the row and column subscripts where the minimum appears. Row and Col are 0007 % column vectors if multiple minimums appear in A. 0008 % 0009 % [MN,Idx] = MINN(A) returns the minimum value MN as well as the linear 0010 % indices Idx of all elements in A that are equal to MN. 0011 % To get the row, column, ..., subscripts associated with the linear indices 0012 % use IND2SUB(size(A),Idx). 0013 0014 % 2004-04-06 0015 % D.C. Hanselman, University of Maine, Orono, ME 04469-5708 0016 0017 if ~isnumeric(A) 0018 error('Numeric Input Expected.') 0019 end 0020 mn=min(A(:)); 0021 0022 if nargout==2 % [MN,idx]=MINN(A) 0023 idx=find(A==mn); 0024 0025 elseif nargout==3 & ndims(A)==2 % [MN,Row,Col]=MINN(A) 0026 [idx,col]=ind2sub(size(A),find(A==mn)); 0027 0028 elseif nargout==3 0029 error('Three Output Arguments Requires 2-D Input.') 0030 end