📄 mmono.m
字号:
function f=mmono(x)%MMONO Test for Monotonic Vector.% MMONO(X) where X is a vector returns:% 2 if X is strictly increasing,% 1 if X is non decreasing,% -1 if X is non increasing,% -2 if X is strictly decreasing,% 0 otherwise.% D.C. Hanselman, University of Maine, Orono, ME, 04469% 2/7/95% Copyright (c) 1996 by Prentice-Hall, Inc.x=x(:); % make x a vectory=diff(x); % find differences between consecutive elementsif all(y>0) f=2; % test for strict firstelseif all(y>=0) f=1;elseif all(y<0) f=-2; % test for strict firstelseif all(y<=0) f=-1;else f=0; % default responseend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -