离散系统的时域分析
- 一、以下程序中分别使用 conv 和 filter 函数计算 h 和 x 的卷积 y 和 y1,运行程序,并分析 y 和 y1 是否有差别,为什么要使用 x[n]补零后的 x1 来产生 y1;具体分析当 h[n]有 i 个值,x[n]有 j 个值,使用 filter 完成卷积功能,需要如何补零?
- 二、编制程序求解下列两个系统的单位冲激响应和阶跃响应,并绘出其图形。要求分别用 filter、 conv、impz 三种函数完成。给出理论计算结果和程序计算结果并讨论。
- 三、听力信号发生器。编写一个频率可调、声音大小可调的函数,实现能产生20Hz到20kHz的响度可调的单频声音信号。
- 四、利用自相关法编程实现声音信号的基音周期估计,观察不同字母、声调的基音变化。
一、以下程序中分别使用 conv 和 filter 函数计算 h 和 x 的卷积 y 和 y1,运行程序,并分析 y 和 y1 是否有差别,为什么要使用 x[n]补零后的 x1 来产生 y1;具体分析当 h[n]有 i 个值,x[n]有 j 个值,使用 filter 完成卷积功能,需要如何补零?
% Program P2_7
clf;
h = [3 2 1 -2 1 0 -4 0 3]; %impulse response
x = [1 -2 3 -4 3 2 1]; %input sequence
y = conv(h,x);
n = 0:14;
subplot(2,1,1);
stem(n,y);
xlabel('Time index n');
ylabel('Amplitude');
title('Output Obtained by Convolution');
grid;
x1 = [x zeros(1,8)];
y1 = filter(h,1,x1);
subplot(2,1,2);
stem(n,y1);
xlabel('Time index n');
ylabel('Amplitude');
title('Output Generated by Filtering');
grid;
答:y和y1没有区别,补零是因为filter的输出长度为x[n]的长度,conv卷积的长度为i+j-1,因此要使用filter 完成卷积功能时需要将x[n] 的长度补到i+j-1,即补j-1个0。
二、编制程序求解下列两个系统的单位冲激响应和阶跃响应,并绘出其图形。要求分别用 filter、 conv、impz 三种函数完成。给出理论计算结果和程序计算结果并讨论。
2.1 第一个系统
num=[1,-1];
den=[1,0.75,0.125];
len1=15;
n=0:len1;
n1=0:2*len1;
xn=[1,zeros(1,15)];
yn=ones(1,16);
hn1=filter(num,den,xn);
sn1=filter(num,den,yn);
subplot(2,3,1