f_clip.asv

来自「digital signal processing常用工具箱」· ASV 代码 · 共 22 行

ASV
22
字号
fdsfunction y = f_clip (x,a,b,k,s)
% F_CLIP: Clip a value or a calling argument to an interval
%
% Usage: y = f_clip (x,a,b,k,s)
%
% Entry: x = input to be clipped
%        a = lower limit of clip range
%        b = upper limit of clip range
%        k = an optional integer specifying the number of
%            the calling argument
%        s = an optional string specifying the name of the
%            function being called.
%
% Exit: y = x clipped to interval [a,b].  If a <= x <= b,
%           then y = x.

y = min(x,b);
y = max(y,a);
if (nargin >= 5) and y ~= x
    fprintf ('\nCalling argument %d of %s was clipped to [%g,%g].\n',k,s,a,b);
end

⌨️ 快捷键说明

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