comcept.m

来自「在Matlab环境下用最小相位法和负倒谱实现的对序列的转换」· M 代码 · 共 43 行

M
43
字号
clear all
%输入x序列
x=input('请输入x序列:');
N=length(x);
n=[1:1:N]
subplot(3,1,1);
stem(n,x);grid on;
title('输入的序列')

%求复倒谱
x=x';
%对x序列进行离散傅立叶变换,用FFT方式
X=fft(x,N);
%取自然对数,+eps避免log0出现
Xcap=log(X+eps);
%对x序列进行逆FFT变换
xcap=ifft(Xcap);

%为避免相位卷绕,使用最小相位法
for i=0:(N-1)
    if (i>=1 && i<=N/2)
        f=2;
    end
    if (i==0 || i==N/2)
        f=1;
    end
    if (i<=N-1 && i>N/2)
        f=0;
    end
    t1(i+1)=xcap(i+1)*f;
end
subplot(3,1,2);
stem(n,t1);grid on;
title('最小相位法得到的序列')

%通过求得的复倒谱,求取原信号
X=fft(t1);
h=exp(X);
x1=ifft(h);
subplot(3,1,3);
stem(n,x1);grid on;
title('由复倒谱恢复得到的序列');

⌨️ 快捷键说明

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