nzsign.m

来自「matlab仿真实现无线传感器网络定位算法」· M 代码 · 共 15 行

M
15
字号
%| nzSIGN  returns the abs() of the first argument if the 2nd argument is
%|    is >= 0.  Otherwise returnd the -abs() of the first argument.
%| 
%| PURPOSE:  written to match "numerical recipes in C" function SIGN.
%|    Unlike matlab's 'sign', a 0.0 value does not force the result to 0.0
%|

function [rval] = nzSIGN(valueArgument, signArgument)

if signArgument >= 0, 
   rval = abs(valueArgument);
else
   rval = -abs(valueArgument);
end

⌨️ 快捷键说明

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