数字信号处理——MATLAB实验(二)

实验名称:离散时间信号和线性时不变离散时间系统的频域分析

一、实验目的:

熟悉Mat lab中的信号处理工具箱及相关命令,掌握用Mat lab验证离散时间傅里叶变换相关性质的方法;掌握用Mat lab分析离散时间系统频域特性的方法并能绘制幅频特性和相频特性图。

二、实验内容及要求:

1. 离散时间信号的频域分析:

(1)修改程序P3.1,在范围 内计算如下序列的离散时间傅里叶变换并绘制幅频特性和相频特性图。
在这里插入图片描述
(2)修改程序P3.2,D=8,验证离散时间傅里叶变换的时移特性并绘图。
(3)修改程序P3.3,w = 0.2π ,验证离散时间傅里叶变换的频移特性并绘图。

2. 线性时不变离散时间系统的频域分析:

(1)修改程序P3.1,计算并画出如下传输函数的频率响应,它是哪种类型的滤波器?
在这里插入图片描述
(2)用Matlab画出如下滤波器的零极点图并分析稳定性。
在这里插入图片描述

三、实验结果及问题回答:

1. 离散时间信号的频域分析:

(1)实验结果:

% Program P3_1
% Evaluation of the DTFT 
clf;
% Compute the frequency samples of the DTFT
w = 0*pi:8*pi/511:pi;
num = [0.7 -0.5 0.3 1];den = [1 0.3 -0.5 0.7];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

在这里插入图片描述
(2)实验结果:

% Program P3_2
% Time-Shifting Properties of DTFT
clf;
w = -pi:2*pi/255:pi; wo = 0.4*pi; D = 8;
num = [1 2 3 4 5 6 7 8 9];
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1));grid
title('Magnitude Spectrum of Original Sequence')
subplot(2,2,2)
plot(w/pi,abs(h2));grid
title('Magnitude Spectrum of Time-Shifted Sequence')
subplot(2,2,3)
plot(w/pi,angle(h1));grid
title('Phase Spectrum of Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2));grid
title('Phase Spectrum of Time-Shifted Sequence')

在这里插入图片描述
(3)实验结果:

% Program P3_3
% Frequency-Shifting Properties of DTFT
clf;
w = -pi:2*pi/255:pi; wo = 0.2*pi;
num1 = [1 3 5 7 9 11 13 15 17];
L = length(num1);
h1 = freqz(num1, 1, w);
n = 0:L-1;
num2 = exp(wo*i*n).*num1;
h2 = freqz(num2, 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1));grid
title('Magnitude Spectrum of Original Sequence')
subplot(2,2,2)
plot(w/pi,abs(h2));grid
title('Magnitude Spectrum of Frequency-Shifted Sequence')
subplot(2,2,3)
plot(w/pi,angle(h1));grid
title('Phase Spectrum of Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2));grid
title('Phase Spectrum of Frequency-Shifted Sequence')

在这里插入图片描述

2. 线性时不变离散时间系统的频域分析:

(1)实验结果:

% Program P3_1
% Evaluation of the DTFT 
clf;
% Compute the frequency samples of the DTFT
w = 0*pi:8*pi/511:1*pi;
num = [0.15 0 -0.15];den = [1 -0.5 0.7];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

在这里插入图片描述
(2)实验结果:

% Program P4_2
% Gain Response of a Moving Average Lowpass Filter
clf;
M = 6;
num = ones(1,M)/M;
[g,w] = gain(num,1);
plot(w/pi,g);grid
axis([0 1 -50 0.5])
xlabel('\omega /\pi');ylabel('Gain in dB');
title(['M = ', num2str(M)])

function [g,w] = gain(num,den)
% Computes the gain function in dB of a 
% transfer function at 256 equally spaced points 
% on the top half of the unit circle
% Numerator coefficients are in vector num
% Denominator coefficients are in vector den
% Frequency values are returned in vector w
% Gain values are returned in vector g
w = 0:pi/255:pi;
h = freqz(num,den,w);
g = 20*log10(abs(h));

在这里插入图片描述
(3)实验结果:

% Program P3_1
% Evaluation of the DTFT 
clf;
% Compute the frequency samples of the DTFT
w = 0*pi:8*pi/511:1*pi;
num = [1 0 0];den = [1 -1.848 0.85 0.7];
h = freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(h));grid
title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));grid
title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_37369201/article/details/83929039