hiltrans.m

来自「JLAB is a set of Matlab functions I have」· M 代码 · 共 55 行

M
55
字号
function[y]=hiltrans(x)%HILTRANS  Hilbert transform.%%   Y=HILTRANS(X) returns the Hilbert transform of column vector X.%%   If SIZE(X,2)>1, HILTRANS takes the Hilbert transform along columns.%%   'hiltrans --f' makes a sample figure%   _________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2004 J.M. Lilly --- type 'help jlab_license' for details          if strcmp(x,'--f')  hiltrans_fig;returnendif isreal(x)  bool=1;else  bool=0;endN=size(x,1);X=fft(x);sgnom=ones(N,1);%sgnom(1)=0;index=[1:N];index=find(index-1>N/2);sgnom(index)=-1;d=-sqrt(-1)*(sgnom);d=oprod(d,1+zeros(size(x(1,:)))');y=ifft(X.*d);%Take real part if real vector was inputif bool  y=real(y);endfunction[]=hiltrans_fign=256;t=[-n:n]';warning offx=1./t;warning onindex=find(~isfinite(x));if ~isempty(index)  x(index)=0;endy=hiltrans(x);figure,plot(cumsum(y))disp('This is a plot of cumsum(hiltrans(1/x))')disp('Hilbert transform of 1/x should be -pi*delta function')

⌨️ 快捷键说明

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