⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isconstant.m

📁 实现地震勘探中
💻 M
字号:
function bool=isconstant(a,epsilon)% Function checks if all elements of array "a" are the same within% limits median(a)*(1 +/- epsilon) (relative error) or,% if median(a) < eps, within limits +/- epsilon (absolute error).%% Written by: E. R.: November 14, 2005% Last updated: April 16, 2008: rewritten to work with matrices%%          bool=isconstant(a,epsilon)% INPUT% a        numeric vector or matrix; if "a" is a matrix, the check is performed% columnwise% epsilon  maximum relative deviation %          Default: epsilon = 0% OUTPUT% bool     logical variable%          true if all entries of "a" are the same within the limits,%          false  otherwise%% EXAMPLE%          bool1=isconstant([1 1 1 1.2],0.5)%          bool2=isconstant(rand(5,7),0.2)[a,nshifts]=shiftdim(a);if nargin == 1  ||  epsilon == 0   bool=all(bsxfun(@eq,a,a(1,:)));else   ma=median(a);   meps=abs(ma*epsilon);   meps(abs(ma)<eps)=abs(epsilon);   bool=all((bsxfun(@le,a,a(1,:)+meps))  &  (bsxfun(@ge,a,a(1,:)-meps))); endbool=shiftdim(bool,-nshifts);

⌨️ 快捷键说明

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