mypower.m

来自「遗传规划的matlab工具箱」· M 代码 · 共 20 行

M
20
字号
function y=mypower(x1,x2)
%MYPOWER    Protected power function.
%   MYPOWER(X1,X2) returns 0 if X1^X2 is NaN or Inf, 
%   or has imaginary part, otherwise returns X1^X2.
%
%   Input arguments:
%      X1 - the base of the power function (double)
%      X2 - the exponent of the power function (double)
%   Output arguments:
%      Y - the power X1^X2, or 0 (double)
%
%   See also MYDIVIDE, MYSQRT, MYLOG, MYLOG2, MYLOG10
%
%   Copyright (C) 2003-2004 Sara Silva (sara@dei.uc.pt)
%   Acknowledgement: Mehrashk Meidani, Shiraz University, (mehrashk@yahoo.com)
%   This file is part of the GPLAB Toolbox

y=x1.^x2;
y(find(isnan(y) | isinf(y) | imag(y)))=0;

⌨️ 快捷键说明

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