minn.m

来自「利用matlab控制3维仿真软件sonnet的工具箱」· M 代码 · 共 30 行

M
30
字号
function [mn,idx,col]=minn(A)
%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).

% 2004-04-06, 2006-03-17
% D.C. Hanselman, University of Maine, Orono, ME  04469-5708

if ~isnumeric(A)
   error('Numeric Input Expected.')
end
mn=min(A(:));

if nargout==2                   % [MN,idx]=MINN(A)
   idx=find(A==mn);
   
elseif nargout==3 && ndims(A)==2 % [MN,Row,Col]=MINN(A)
   [idx,col]=find(A==mn);
   
elseif nargout==3
   error('Three Output Arguments Requires 2-D Input.')
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?