Digital Signal Processing Experiment 1 Time Domain Sampling and Frequency Domain Sampling [Experiment Report]

Tip: After the article is written, the table of contents can be automatically generated. For how to generate it, please refer to the help document on the right.

Preface

数字信号处理 实验一 时域采样与频域采样【实验报告】

1. Verification of time domain sampling theory

1. Verification of time domain sampling theory. Given an analog signal,
where A=444.128, a =50 π, w0 =50 πrad/s, its amplitude-frequency characteristic curve is shown in Figure 1.1
Amplitude-frequency characteristic curve of xa(t)

              图1.1   xa(t)的幅频特性曲线

Now use DFT (FFT) to find the amplitude-frequency characteristics of the analog signal to verify the time domain sampling theory. According to the amplitude-frequency characteristic curve of xa(t), three sampling frequencies are selected, namely Fs=1kHz, 300Hz, and 200Hz. The observation time is selected as Tp=50ms. To use DFT, first use the following formula to generate a time domain discrete signal. For three sampling frequencies, the sampling sequence is represented by x1(n), x2(n), x3(n) in order.
Insert image description hereBecause the sampling frequencies are different, the lengths of x1(n), x2(n), and x3(n) obtained are different. The length (number of points) is Insert image description here
calculated using the formula. Select the number of transformation points of FFT as M=64, and add zero to the tail if the sequence length is less than 64.
X(k)=FFT[x(n)], k=0,1,2,3,-----,M-1. The frequency represented by k in the formula is Insert image description here
Requirements: Write an experimental program, calculate the amplitude characteristics of x1(n), x2(n), and x3(n), and display them in a drawing. Observe and analyze spectral aliasing distortion.

Program List

clear all
clc
%Fs=1000Hz
Tp = 64/1000;
Fs = 1000; T = 1/Fs;
M = Tp*Fs; n=0:M-1;
A = 444.128; alph = pi*50*2^0.5; omega = pi*50*2^0.5;
xnt = A*exp(-alph*n*T).*sin(omega*n*T);
Xk = T*fft(xnt,M); 
yn1 = 0:length(xnt)-1;
subplot(3,2,1);stem(yn1,xnt,'.');xlabel('n');ylabel('xa(n*T)');title('x1(n)的幅度特性,Fs=1000Hz');
k = 0:M-1; fk = k/Tp;
subplot(3,2,2);plot(fk,abs(Xk));xlabel('f(Hz)');ylabel('幅度');title('T*FT[xa(nT)],Fs=1000Hz');
%Fs=2000Hz
Tp = 64/1000;
Fs = 2000; T = 1/Fs;
M = Tp*Fs; n=0:M-1;
A = 444.128; alph = pi*50*2^0.5; omega = pi*50*2^0.5;
xnt = A*exp(-alph*n*T).*sin(omega*n*T);
Xk = T*fft(xnt,M); 
yn1 = 0:length(xnt)-1;
subplot(3,2,3);stem(yn1,xnt,'.');xlabel('n');ylabel('xa(n*T)');title('x1(n)的幅度特性,Fs=2000Hz');
k = 0:M-1; fk = k/Tp;
subplot(3,2,4);plot(fk,abs(Xk));xlabel('f(Hz)');ylabel('幅度');title('T*FT[xa(nT)],Fs=2000Hz');
%Fs=200Hz
Tp = 64/1000;
Fs = 200; T = 1/Fs;
M = Tp*Fs; n=0:M-1;
A = 444.128; alph = pi*50*2^0.5; omega = pi*50*2^0.5;
xnt = A*exp(-alph*n*T).*sin(omega*n*T);
Xk = T*fft(xnt,M); 
yn1 = 0:length(xnt)-1;
subplot(3,2,5);stem(yn1,xnt,'.');xlabel('n');ylabel('xa(n*T)');title('x1(n)的幅度特性,Fs=200Hz');
k = 0:M-1; fk = k/Tp;
subplot(3,2,6);plot(fk,abs(Xk));xlabel('f(Hz)');ylabel('幅度');title('T*FT[xa(nT)],Fs=200Hz');
operation result

Insert image description here

analyze

When the sampling frequency is 1000Hz or 2000Hz, the spectrum is almost undistorted; when the sampling frequency is 200Hz, the spectrum aliasing distortion is more serious. As can be seen from the figure, the spectrum
of the sampling sequence is indeed a periodic delay of the analog signal spectrum with the sampling frequency as the period. Extension. When the sampling frequency is 1000Hz and 2000Hz, the spectrum aliasing is very small; when the sampling frequency is 200Hz, the spectrum aliasing is serious near the frequency of 100Hz.

2. Verification of time domain sampling theory

  1. Verification of frequency domain sampling theory.
    The given signal is as follows:
    Insert image description here

Write a program to Insert image description here
sample 32
and 16 points of the spectrum function at equal intervals in the interval [0,2*pi], and obtain X32(k) and X16(k):
Insert image description here
Insert image description here

Then perform 32-point and 16-point IFFT on the pairs respectively, and get Insert image description here
:
Insert image description here

Draw the amplitude spectra of respectively Insert image description here
and display the waveforms of x(n), X32(k) and X16(k) for comparison and analysis to verify and summarize the frequency domain sampling theory.
Tip: Frequency domain sampling can be easily implemented in a program using the following method.
① Directly call the MATLAB function fft to calculate 32(k)=FFT[x(n)] and you will get 32-point frequency domain samplingInsert image description here
at [0,2 pi] ② Extract the even points of X32(k) and you will get it at [0, 2 pi] 16-point frequency domain sampling, that is
Insert image description here
Insert image description here

○3 Of course, you can also follow the frequency domain sampling theory, first extend the signal x(n) with a period of 16, take its main value area (16 points), and then perform a 16-point DFT (FFT) on it to get That is, Insert image description here
sampling X16(k) in the 16-point frequency domain of [0,2*pi].

Program List

%DTFT
M=27;
n=0:M;
k=0:1023;
wk=2*k/1024;
Xk=fft(xn,1024);
subplot(3,2,1);
plot(wk,abs(Xk));title('DTFT[x(n)]');
%三角波序列
clear all
clc
xn=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,13,12,11,10,9,8,7,6,5,4,3,2,1];
n=0:27-1;
subplot(3,2,2);
stem(n,xn);title('三角波序列');xlabel('n');ylabel('x(n)');
%(2)32点DFT:X(k)
xn=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,13,12,11,10,9,8,7,6,5,4,3,2,1];
xn=[xn,ones(1,32-27)];
n1=1:32;
X32k=fft(xn,32);
x32n =ifft(X32k); 
subplot(3,2,3);
stem(n1,abs(X32k),'.');title('32点DFT:X(k)');xlabel('k');ylabel('X(k)');
subplot(3,2,4);
stem(n1,abs(x32n),'.');title('32点IDFT:x(n)');xlabel('n');ylabel('x(n)');
%(2)16点DFT:X(k)
clear all
clc
xn=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,13,12,11,10,9,8,7,6,5,4,3,2,1];
n2=1:16;
xn=[12,12,12,12,12,12,12,12,12,12,12,12,13,14,13,12]
X16k=fft(xn,16);
x16n =ifft(X16k); 
subplot(3,2,5);
stem(n2,abs(X16k),'.');title('16点DFT:X(k)');xlabel('k');ylabel('X(k)');
subplot(3,2,6);
stem(n2,abs(x16n),'.');title('16点IDFT:x(n)');xlabel('n');ylabel('x(n)');
operation result

Insert image description here

analyze

If the time domain length is M, when N ≥ M, after the time domain period extension, the sequence of the main value interval is equal to the original sequence without distortion. When N<M, there will be aliasing distortion in the time domain. At this time, there is no aliasing distortion only in the range of MN≤n≤N-1.
This figure verifies the frequency domain sampling theory and frequency domain sampling theorem. When the spectrum function of signal x(n) is sampled N=16 at equal intervals on [0, 2π], the sequence obtained by N-point IDFT[XN(k)] is exactly the original sequence x(n) with a period of 16. The extended main value area sequence. Since N<M, time domain aliasing distortion occurs, therefore. xN(n) is not the same as x(n).
When N=32, due to N>M and the frequency domain sampling theorem, there is no time domain aliasing distortion. Therefore, xN(n) is the same as x(n).

3.Thinking questions

If the length of the sequence x(n) is M, we want to obtain Insert image description here
N-point equally spaced samples of its spectrum on [0,2*pi]. When N<M, how to obtain the spectrum samples using a DFT with the minimum number of points?

analyze

When finding the N-point discrete spectrum where the number of frequency domain sampling points N is less than the original time domain sequence length M, the original sequence x(n) can be periodically extended with N as the period, and then the main value area sequence is obtained, and then the N points are Insert image description here
calculated DFT obtains N-point frequency domain samplesbold style


Summarize

This article is an experimental report of digital signal processing experiment 1 based on MATLAB.

Guess you like

Origin blog.csdn.net/m0_53229990/article/details/127667207