iseven.m

来自「linear time-frequency toolbox」· M 代码 · 共 67 行

M
67
字号
function t=iseven(f,centering,tol);%ISEVEN  True if function is even%   Usage:  t=iseven(f);%           t=iseven(f,centering);%           t=iseven(f,centering,tol);%%   ISEVEN(f) returns 1 if f is whole point even. Otherwise it returns 0.%%   ISEVEN(f,centering) is true if f is even according to%   the value of centering: 0 indicates a whole-point even function%   and 0.5 indicates a half-point even function.  %%   ISEVEN(f,centering,tol) does the same, using the tolerance tol%   to measure how large the error between the two parts of the vector%   can be. %if size(f,2)>1  if size(f,1)>1    error('f must be a vector');  else    % f was a row vector.    f=f(:);  end;end;if nargin<3  tol=1e-10;end;if nargin<2  centering=0;end;L=size(f,1);switch centering  case 0    % Determine middle point of sequence.    if rem(L,2)==0      middle=L/2;    else      middle=(L+1)/2;    end;        % Relative norm of difference between the parts of the signal.    d=norm(f(2:middle)-conj(flipud(f(L-middle+2:L))))/norm(f);  case .5        middle=floor(L/2);    d=norm(f(1:middle)-conj(flipud(f(L-middle+1:L))))/norm(f);    otherwise      error('Unsupported centering.');  end;% Return true if d less than tolerance.t=d<=tol;

⌨️ 快捷键说明

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