minmax - Return overall min and max values for any number of arrays. USAGE [m,i] = minmax(x,y,...) x,y,... variables OUTPUT m minima and maxima of x,y,... (one pair per line) i indices of minimum and maximum values
0001 %minmax - Return overall min and max values for any number of arrays. 0002 % 0003 % USAGE 0004 % 0005 % [m,i] = minmax(x,y,...) 0006 % 0007 % x,y,... variables 0008 % 0009 % OUTPUT 0010 % 0011 % m minima and maxima of x,y,... (one pair per line) 0012 % i indices of minimum and maximum values 0013 0014 % Copyright (C) 2015 by Michaƫl Zugaro 0015 % 0016 % This program is free software; you can redistribute it and/or modify 0017 % it under the terms of the GNU General Public License as published by 0018 % the Free Software Foundation; either version 3 of the License, or 0019 % (at your option) any later version. 0020 0021 function [m,i] = minmax(varargin) 0022 0023 if nargin < 1, 0024 error('Incorrect number of parameters (type ''help <a href="matlab:help minmax">minmax</a>'' for details).'); 0025 end 0026 0027 for k = 1:length(varargin), 0028 v = varargin{k}; 0029 [m(k,1),i(k,1)] = min(v(:)); 0030 [m(k,2),i(k,2)] = max(v(:)); 0031 end