www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@guidarray/private/isMonotonic.m
function IS_MONOTONIC = isMonotonic(value) %ISMONOTONIC Check that a vector is monotonically increasing % % ISMONOTONIC(VECT) returns true if VECT is a monotonically increasing % vector. % Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc. % Initialse the loop variables i = 1; numValues = length(value); % Loop until the end of the array or not monotonic - Note this loop is JIT % compiled and hence faster than vectorised code while i < numValues && value(i+1) > value(i) i = i + 1; end % Was monotonic if entire array was covered IS_MONOTONIC = i == numValues;