zhangchuan 发表于 2006-9-18 12:36

【原创】离散数字信号微分

前几天遇到做数字信号微分,到论坛没有找到,回去自己找了些资料编写了一个,现拿来和大家共享下哦。在微分时注意参数的选取。

functionfgm=fgmdif(sig,ts,ft,n,m,n1)
%sig离散信号
% ts采样间隔
% fs微分截止频率
% N1 信号长度
% M 所采用的窗函数的半宽度
% N做FFT的长度,N=2的M次方且满足N>=N1+2m.
p=2*ft*ts;
h=zeros(1,2*m);
forn2=0:2m-1
    ifn2==m
      h(n2+1)=0;
    else
      g=pi*p*(n2-m);
      h1=1-cos(pi*n2/m);
      h2=g*cos(g)-sin(g);
      h(n2+1)=h2/(2*pi*ts)*h1/(n2-m)^2;
    end
end
fsig=fft(sig,n);
fh=fft(h,n);
z=conv(sig,fh);
z1=ifft(z);
fgm=real(z1);
for n3=0:n1-1
    fgm(n3+1)=fgm(n3+1+m);
end
for n3=n1:n1-1+2*m-1
    fgm(n3+1)=0;
end

eight 发表于 2006-9-18 12:57

原帖由 zhangchuan 于 2006-9-18 12:36 发表
前几天遇到做数字信号微分,到论坛没有找到,回去自己找了些资料编写了一个,现拿来和大家共享下哦。在微分时注意参数的选取。

functionfgm=fgmdif(sig,ts,ft,n,m,n1)
%sig离散信号
% ts采样间隔
% ...


支持,不过代码可以再改进一下,没有必要用到循环

AaronSpark 发表于 2006-9-19 03:36

A Matlab Differentiation Matrix Suite

This is a software suite designed for MATLAB 5 consisting of seventeen functions for solving differential equations by the spectral collocation (a.k.a. pseudospectral) method. It includes functions for computing differentiation matrices of arbitrary order corresponding to Chebyshev, Hermite, Laguerre, Fourier, and sinc interpolants. It also includes FFT-based routines for Fourier, Chebyshev and sinc differentiation. Auxiliary functions are included for incorporating boundary conditions, performing interpolation using barycentric formulas, and computing roots of orthogonal polynomials.

In the accompanying paper it is demonstrated how to use the package for solving eigenvalue, boundary value, and initial value problems arising in the fields of special functions, quantum mechanics, nonlinear waves, and hydrodynamic stability.

Paper

Download the compressed version of the paper (paper.ps.gz, gzipped PostScript 0.4MB), or the uncompressed version (paper.ps, PostScript 1.2MB).

Functions

We have made every effort to test these functions. However, NO GUARANTEES are made about their validity. Please contact us at weideman@math.orst.edu or reddy@math.orst.edu if you find bugs or have comments!

The entire set of functions is available in atar file. To process, issue the command

tar -xvf dmsuite.tar

For a .zip version, please go to this MathWorks site.

Individual files can also be downloaded as text files:
Table of Contents

Contents.m
Differentiation Matrices (Polynomial Based)

poldif.m (General differentiation matrices)
chebdif.m (Chebshev differentiation matrices)
herdif.m (Hermite differentiation matrices)
Requires: herroots.m, poldif.m
lagdif.m (Laguerre differentiation matrices)
Requires: lagroots.m, poldif.m
Differentiation Matrices (Non-Polynomial)

fourdif.m (Fourier differentiation matrices)
sincdif.m (Sinc differentiation matrices)
Boundary Conditions

cheb2bc.m (Chebyshev 2nd derivative matrix incorporating Robin boundary conditions)
Requires: chebdif.m
cheb4c.m (Chebyshev 4th derivative matrix incorporating clamped boundary conditions)
Interpolation

polint.m (Barycentric polynomial interpolation on arbitrary distinct nodes)
chebint.m (Barycentric polynomial interpolation on Chebyshev points)
fourint.m (Barycentric trigonometric interpolation at equidistant nodes)
Transform-Based Derivatives

chebdifft.m (FFT-based Chebyshev derivative)
fourdifft.m (FFT-based Fourier derivative)
sincdifft.m (FFT-based sinc derivative)
Roots of Orthogonal Polynomials

legroots.m (Roots of Legendre polynomials)
lagroots.m (Roots of Laguerre polynomials)
herroots.m (Roots of Hermite polynomials)
Examples

cerfa.m (Function file for computing complementary error function. BC y(infinity) = 0.
Requires: chebdif.m, chebint.m
cerfb.m (Function file for computing complementary error function. BC y(0) = 1
Requires: chebdif.m, chebint.m
matplot.m (Script file for plotting characteristic curves of Mathieu's equation)
Requires: fourdif.m
ce0.m (Function file for computing the Mathieu cosine elliptic function)
Requires: fourdif.m, fourint.m
sineg.m (Script file for solving the sine-Gordon equation)
Requires: herdif.m, herroots.m, sincdif.m, fourdif.m, poldif.m, sgrhs.m,
sgrhs.m (Function file for computing the right-hand side of the sine-Gordon equation)
schrod.m (Script file for computing the eigenvalues of the Schrodinger equation)
Requires: lagdif.m, lagroots.m, poldif.m
orrsom.m (Script file for computing the eigenvalues of the Orr-Sommerfeld equation)
Requires: cheb4c.m, chebdif.m
页: [1]
查看完整版本: 【原创】离散数字信号微分