iseven.m

来自「Matlab时频分析工具箱,希望能对大家有所帮助啊」· M 代码 · 共 80 行

M
80
字号
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. %% This program is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.% % This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the% GNU General Public License for more details.% % You should have received a copy of the GNU General Public License% along with this program.  If not, see <http://www.gnu.org/licenses/>.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 + -
显示快捷键?