mylog.m
来自「遗传规划的matlab工具箱」· M 代码 · 共 21 行
M
21 行
function y=mylog(x)
%MYLOG Protected LOG function, equal to Koza.
% MYLOG(X) returns zero if X=0 and LOG(ABS(X)) otherwise.
%
% Input arguments:
% X - the number to log (double)
% Output arguments:
% Y - the natural logarithm of X, or zero (double)
%
% See also MYLOG2, MYLOG10, MYSQRT, MYDIVIDE, MYPOWER
%
% Copyright (C) 2003-2004 Sara Silva (sara@dei.uc.pt)
% This file is part of the GPLAB Toolbox
% fill the cells where x=0 (make them 0):
y=zeros(size(x));
% fill the remaining cells with the result of the logarithm:
i=find(x~=0);
y(i)=log(abs(x(i)));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?