声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3547|回复: 2

[编程技巧] 【原创】离散数字信号微分

[复制链接]
发表于 2006-9-18 12:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

function  fgm=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);
for  n2=0:2m-1
    if  n2==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

评分

1

查看全部评分

回复
分享到:

使用道具 举报

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

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



支持,不过代码可以再改进一下,没有必要用到循环
发表于 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 a  tar 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

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-20 00:48 , Processed in 0.071980 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表