Experimental content
Experimental purpose
Time domain sampling theory and frequency domain sampling theory are important theories in digital signal processing. It is required to master the changes in the spectrum of analog signals before and after sampling, and how to choose the sampling frequency so that the sampled signal does not lose information; it is required to master the concept that frequency domain sampling will cause time domain periodization, as well as the frequency domain sampling theorem and its application to frequency domain sampling. Point selection guide.
Experimental principles and methods
The key points of the time domain sampling theorem are:
(1) For analog signalsPerform equal-spaced ideal sampling in the time domain at intervals T, resulting in the spectrum of the sampled signal is the spectrum of the original analog signal With sampling angular frequency Period continuation for the cycle. The formula is:
Sampling frequencyMust be greater than or equal to twice the highest frequency of the analog signal so that the spectrum of the sampled signal does not produce spectrum aliasing.
It is not convenient to use a computer to calculate the above formula. Below we derive another formula to facilitate experiments on a computer.
Ideal sampled signaland analog signal is:
Perform Fourier transform on the above equation to get:
In the integral sign of the above formula, there is a non-zero value only when t=nT, therefore:
In the above formula, numerically , then to get:
The right side of the above formula is the Fourier transform of the sequence , that is
The above formula shows that the Fourier transform of the ideal sampling signal can be obtained by the Fourier transform of the corresponding sampling sequence, as long as the independent variable Use Just replace it.
The key points of the frequency domain sampling theorem are:
Spectral function of signal x(n)Sampling N points at equal intervals on [0, 2π], we get
Then N pointThe obtained sequence is the main value area sequence after periodic extension of the original sequence x(n) with N as the period.
The formula is:
It can be seen from the above formula that the number of sampling points N in the frequency domain must be greater than or equal to the length M of the discrete signal in the time domain (that is, N≥M), so that aliasing does not occur in the time domain, then point N]obtained SequenceIt is the original sequence x(n), that is, . If N>M, N-M more zero points than the tail of the original sequence; if N
In the application of digital signal processing, as long as time domain or frequency domain sampling is involved, the key points of these two sampling theories must be obeyed.
Comparing the time domain sampling principle and the frequency domain sampling principle described above, a useful conclusion is drawn. These two sampling theories have duality: “time domain sampling spectrum period extension, frequency domain sampling time domain signal period extension”. So put them together for experiments.
Experimental content and steps
Verification of time domain sampling theory. Given analog signal
In the formula, A=444.128, , Its amplitude-frequency characteristics The curve is as shown in the figure
Amplitude-frequency characteristic curve
Now use DFT (FFT) to find the amplitude-frequency characteristics of the analog signal to verify the time domain sampling theory.
Follow ‘s amplitude-frequency characteristic curve, select three sampling frequencies, namely ?=1kHz, 300Hz, 200Hz. Select the observation time ? =50ms.
To use DFT, first use the following formula to generate a time domain discrete signal. For three sampling frequencies, the sampling sequence is in order: means.
Because the sampling frequencies are different, the obtainedare different lengths, and the length (number of points) is FormulaCalculation. 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.
In the formula, the frequency represented by k is .
Requirements: Write experimental programs and calculate amplitude properties and plotted. Observe and analyze spectral aliasing distortion.
Verification of frequency domain sampling theory. The given signal is as follows:
Write a program to analyze the spectrum functions respectively and:
Then perform 32-point and 16-point IFFT on and respectively, and get and:
Draw each 、andamplitude spectrum, and plot to display x(n), mathcode” src=”//i2.wp.com/latex.csdn.net/eq?x_{32}(k)”>andwaveforms are compared and analyzed to verify and summarize the frequency domain sampling theory. .
Tips: Frequency domain sampling can be easily implemented in a program using the following method.
Directly call the MATLAB function fft to calculate You will getat [ 0 , 2 π ]’s 32-point frequency domain sampling.
ExtractYou can get even pointsSampling in the 16-point frequency domain of [0,2π], that is.
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, and the result is < img alt="X(e^{j\omega})" class="mathcode" src="//i2.wp.com/latex.csdn.net/eq?X(e^{ j\omega})">Sampling in the 16-point frequency domain of [0,2π].
Experimental Procedure
% "Digital Signal Processing (4th Edition)" Chapter 10 Experiment 2 Program exp2b.m % Published by Xi'an University of Electronic Science and Technology Press, co-authored by Gao Xiquan and Ding Yumei, 2016 % Frequency domain sampling theory verification M=27;N=32;n=0:M; %Generate M long triangle wave sequence x(n) xa=0:floor(M/2); xb= ceil(M/2)-1:-1:0; xn=[xa,xb]; Xk=fft(xn,1024); 24-point FFT[x(n)], used to approximate the TF of the sequence x(n) X32k=fft(xn,32);2-point FFT[x(n)] x32n=ifft(X32k); 2 points IFFT[X32(k)] gets x32(n) X16k=X32k(1:2:N);% extract X32k at every other point to get X16(K) x16n=ifft(X16k,N/2); Click IFFT[X16(k)] to get x16(n) subplot(3,2,2);stem(n,xn,'.');box on title('(b) triangle wave sequence x(n)');xlabel('n');ylabel('x(n)');axis([0,32,0,20]) k=0:1023;wk=2*k/1024; subplot(3,2,1);plot(wk,abs(Xk));title('(a)FT[x(n)]'); xlabel('\omega/\pi');ylabel('|X(e^j^\omega)|');axis([0,1,0,200]) k=0:N/2-1; subplot(3,2,3);stem(k,abs(X16k),'.');box on title('(c) 16-point frequency domain sampling');xlabel('k');ylabel('|X_1_6(k)|');axis([0,8,0,200]) n1=0:N/2-1; subplot(3,2,4);stem(n1,x16n,'.');box on title('(d) 16-point IDFT[X_1_6(k)]');xlabel('n');ylabel('x_1_6(n)');axis([0,32,0, 20]) k=0:N-1; subplot(3,2,5);stem(k,abs(X32k),'.');box on title('(e) 32-point frequency domain sampling');xlabel('k');ylabel('|X_3_2(k)|');axis([0,16,0,200]) n1=0:N-1; subplot(3,2,6);stem(n1,x32n,'.');box on title('(f) 32-point IDFT[X_3_2(k)]');xlabel('n');ylabel('x_3_2(n)');axis([0,32,0, 20])
% "Digital Signal Processing (4th Edition)" Chapter 10 Experiment 2 Program exp2a.m % Published by Xi'an University of Electronic Science and Technology Press, co-authored by Gao Xiquan and Ding Yumei, 2016 % Time domain sampling theory verification Tp=64/1000; %Generate M long sampling sequence x(n) % Fs=1000;T=1/Fs; 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); %M point FFT[xnt)] yn='xa(nT)'; subplot(3,2,1);tstem(xnt,yn);box on;title('(a) Fs=1000Hz'); k=0:M-1;fk=k/Tp; subplot(3,2,2);plot(fk,abs(Xk));title('(a) T*FT[xa(nT)],Fs=1000Hz'); xlabel('f(Hz)'); ylabel('amplitude');axis([0,Fs,0,1.2*max(abs(Xk))]) % Fs=300;T=1/Fs; Fs=300;T=1/Fs; M=ceil(Tp*Fs);n=0:M-1; xnt=A*exp(-alph*n*T).*sin(omega*n*T); Xk=T*fft(xnt,M); %M point FFT[xnt)] yn='xa(nT)'; subplot(3,2,3);tstem(xnt,yn);box on;title('(b) Fs=300Hz'); k=0:M-1;fk=k/Tp; subplot(3,2,4);plot(fk,abs(Xk));title('(b) T*FT[xa(nT),Fs=300Hz'); xlabel('f(Hz)');ylabel('amplitude');axis([0,Fs,0,1.2*max(abs(Xk))]) % Fs=200;T=1/Fs; Fs=200;T=1/Fs; M=ceil(Tp*Fs);n=0:M-1; xnt=A*exp(-alph*n*T).*sin(omega*n*T); Xk=T*fft(xnt,M); %M point FFT[xnt)] yn='xa(nT)';subplot(3,2,5);tstem(xnt,yn);box on;title('(c) Fs=200Hz'); k=0:M-1;fk=k/Tp; subplot(3,2,6);plot(fk,abs(Xk));title('(c) T*FT[xa(nT),Fs=200Hz'); xlabel('f(Hz)');ylabel('amplitude');axis([0,Fs,0,1.2*max(abs(Xk))])
function tstem(xn,yn) %Time domain sequence drawing function % xn: signal data sequence, yn: ordinate name of the drawing signal (string) n=0:length(xn)-1; stem(n,xn,'.'); xlabel('n');ylabel(yn); axis([0,n(end),min(xn),1.2*max(xn)])
Experimental results
Experimental result analysis and experimental summary
It can be seen from Figure 1 that the spectrum of the sampling sequence is indeed a periodic continuation of the spectrum of the analog signal with the sampling frequency as the period. When the sampling frequency is 1000Hz, the spectrum aliasing is very small; when the sampling frequency is 300Hz, the spectrum aliasing is serious near the folding frequency 150Hz; when the sampling frequency is 200Hz, the spectrum aliasing is even more serious near the folding frequency 110Hz.
Figure 2 verifies the frequency domain sampling theory and frequency domain sampling theorem. Spectral function of signal x(n)When sampling N=16 at equal intervals on [0,2π], N pointsThe obtained sequence is exactly the original sequence x(n) starting from 16 is the main value area sequence after period extension:
Since N