noneg2.m

来自「这是《Numerical Methods with MATLAB: Imple」· M 代码 · 共 8 行

M
8
字号
function y = noneg2(x)
% noneg2  Returns x if x>0, otherwise prints an error message and stops.
%         The error message contains the value of x.
if x<0
  error(sprintf('x = %f cannot be negative',x));
end
y = x;

⌨️ 快捷键说明

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