args.m
来自「matlab算法集 matlab算法集」· M 代码 · 共 29 行
M
29 行
function y = args (x,a,b,k,f)
%-----------------------------------------------------------------------
% Usage: y = args (x,a,b,k,f)
%
% Description: Check to see if a scalar calling argument is out of range
%
% Inputs: x = scalar to be checked
% a = minimum value of x
% b = maximum value of x
% k = argument number
% f = string containing function name
%
% Outputs: y = x saturated to the interval [a,b]
%-----------------------------------------------------------------------
if x < a
y = a;
fprintf ('\nArgument %i of function %s was too low. Its value',k,f)
fprintf ('\nwas set to %g.\n',y)
elseif x > b
y = b;
fprintf ('\nArgument %i of function %s was too high. Its value',k,f)
fprintf ('\nwas set to %g.\n',y)
else
y = x;
end
%-----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?