当前位置:文档之家› DSP基础知识学习笔记

DSP基础知识学习笔记

ELCE705 Digital Signal ProcessingSimulation Project Report 1University of MacauYibo Han MB-5-5548-4IntroductionIn this project, I have finished the simulation of discrete signals such as impulse signals, step signals, and discrete-time cosine signals in different time and frequency domains, respectively. Then I did the simulation of average system, plotted the results and made contractive analysis. MATLAB ExercisesProblem 1: Basic discrete sequences(a)The given signal is:x(n)=e jwn, n=1, 2, … 30(1-1-1) The value of w is known as 0.3. So we could use the function real and imag to draw the real part and imaginary part directly. The results will be two discrete curves.The program is shown as follows:n=(1:30);w=0.3;x=exp(j*w*n);subplot(2,1,1);stem(n,real(x));title('Real parts');xlabel('Time index n' );ylabel('Amplitude');subplot(2,1,2);stem(n,imag(x));title('Imaginary parts');xlabel('Time index n' );ylabel('Amplitude');The figure is shown as follows:Fig 1.1.1 The real and imaginary parts of x(n)In MATLAB program, we can use the function abs and angle to provide the magnitude and phase angle of x(n). These two curves are discrete as well since time index n is discrete.The program is shown as follows:n=(1:1:30);w=0.3;x=exp(j*w*n);subplot(2,1,1);stem(n,abs(x));title('Magnitude');xlabel('Time index n' );ylabel('Amplitude');subplot(2,1,2);stem(n,angle(x));title('Phase');xlabel('Time index n' );ylabel('Phase');The figure is shown as follows:Fig 1.1.2 The magnitude and Phase angle of x(n)(b)In order to create unit impulse signal δ[n-8] and unit step signal u[n-10], we could first provide unit impulse signal δ[n] and unit step signal u[n], then move them right side 8 or 10 units on xlabel. In this part, I use the function stem to draw discrete signal results.The program is shown as follows:n=(1:30);n0=1;x1=[(n-n0)-8==0];subplot(2,1,1);stem(n,x1);title('x1[n]=δ[n-8]');xlabel('Time index n' );ylabel('Amplitude');x2=[(n-n0)-10>=0];subplot(2,1,2);stem(n,x2);title('x2[n]=u[n-10]');xlabel('Time index n' );ylabel('Amplitude');The figure is shown as follows:Fig 1.1.3 Figures of unit sig nals δ[n-8] and u[n-10](c)In this part, I used the same way in part (b) to draw the unit stepsignals u[n-5] and u[n-8]. Then I defined a function x2[n]=u[n-5]-u[n-8] in the program and drawn it.The program is shown as follows:n=(0:30);n0=0;x0=[(n-n0)-5>=0];x1=[(n-n0)-8>=0];x2=x0-x1;subplot(3,1,1);stem(n,x0);title('x0[n]=u[n-5]');xlabel('Time index n' );ylabel('Amplitude');subplot(3,1,2);stem(n,x1);title('x1[n]=u[n-8]');xlabel('Time index n' );ylabel('Amplitude');subplot(3,1,3);stem(n,x2);title('x2[n]=u[n-5]-u[n-8]');xlabel('Time index n' );ylabel('Amplitude');The figure is shown as follows:Fig 1.1.4 Procedure for plotting x2[n]=u[n-5]-u[n-8]Problem 2: Discrete sinusoidal sequences(a)In this part, we have a discrete-time cosine sequences. It is shown as: x(t)=A·cos(2πƒn) (1-2-1) A is valued as 1.5, and ƒranged of 4 values as 0, 0.125, 0.25, 0.5. I used the function stem to plot these four figures and put them in one picture to make further comparison.The program is shown as follows:n=(0:1:30);A=1.5;f0=0;x0=A*cos(2*pi*f0*n);subplot(2,2,1);stem(n,x0);title('x(t) (f=0)');xlabel('Time index n' );ylabel('Amplitude'); f1=0.125;x1=A*cos(2*pi*f1*n);subplot(2,2,2);stem(n,x1);title('x(t) (f=0.125)');xlabel('Time index n' );ylabel('Amplitude'); f2=0.25;x2=A*cos(2*pi*f2*n);subplot(2,2,3);stem(n,x2);title('x(t) (f=0.25)');xlabel('Time index n' );ylabel('Amplitude'); f3=0.5;x3=A*cos(2*pi*f3*n);subplot(2,2,4);stem(n,x3);title('x(t) (f=0.5)');xlabel('Time index n' );ylabel('Amplitude'); The figure is shown as follows:Fig 1.2.1 Discrete signals of x(t) with different values of ƒThe figure 1.2.1 shows that as the value of ƒincreased, the period of function x(t)=A·cos(2πƒn) got shorter. When ƒequals to zero, the amplitude of x(t) at every point of time index n will be a fixed value of 1.5, which equals to the value of A. This is because when ƒ=0, x(t)=A·cos(2π·0·n)=A. When ƒincreases, the period of function x(t) gets shorter as the result of follow calculating:T=2π/w=2π/2πƒ=1/ƒ(1-2-2) T refers to the period of Function x(t).(b)When we changes the discrete-time sequences x(t)= A·cos(2πƒn)for n=0 ~ 40, and ƒranges from 0.2 to 1.2, the figure will be generated bythe same method in part (a). I used function stem to draw these figures. The program is shown as follows:n=(0:1:40);A=1.5;f0=0.2;x0=A*cos(2*pi*f0*n);subplot(2,1,1);stem(n,x0);title('x(t) (f=0.2)');xlabel('Time index n' );ylabel('Amplitude');f1=1.2;x1=A*cos(2*pi*f1*n);subplot(2,1,2);stem(n,x1);title('x(t) (f=1.2)');xlabel('Time index n' );ylabel('Amplitude');f2=0.25;The figure is shown as follows:Fig 1.2.2 Figures of x(t) with ƒ=0.2 and ƒ=1.2The figure 1.2.2 shows that when ƒ=0.2 and ƒ=1.2, the two figures just look the same. If we define T0 as the period of x(t) (ƒ=0.2) and T1 as the period of x(t) (ƒ=1.2), we can calculate by using formula (1-2-2) and get the result that T0=5 and T1=5/6, then we can find that T0=6·T1. As we know, periodic function has a quality that if T (T should not be valued as 0) is the period of certain function, then n·T is also the period of this certain function (n should not be valued as 0). So the conclusion is that when ƒ=0.2 and ƒ=1.2, the figures show a same periodic function x(t). Problem 3: Average system(a)In this part, we need to get an understanding of how average system works. The given function is a two-point average algorithm y[n]=1/2(x[n]+x[n-1]). I used the given program to generate the figure of results.The program is shown as follows:r=51;d=0.8*(rand(r,1)-0.5);m=0:r-1;s=2*m.*(0.8.^m);x=s+d';subplot(2,1,1)plot(m,d','r', m, s, 'g', m,x, 'b');xlabel('Time index n'); ylabel('Amplitude');legend('d[n]', 's[n]', 'x[n]');x1=[0 x]; x2=[x 0];y=(x1+x2)/2;subplot(2,1,2);plot(m, y(1:r), 'r', m, s,'b');xlabel('Time index n'); ylabel('Amplitude');legend('y[n]', 's[n]');The figure is shown as follows:Fig 1.3.1 Figures of y[n]=1/2(x[n]+x[n-1])(b)In this part, the given function is changed as y[n]=1/3(x[n]+x[n-1]+x[n-2]), and all the other function values remain unchanged as in part 1. In part 1, we used row vector to indicate x[n] and x[n-1]. We can put an 0 unit in front of the row vector x[n] and change itto row vector x[n-1]. In contrast, we also need to put an 0 unit after the row vector x[n] to make the two row vectors to add together with a same number of digit units, and this operation will not change the value of x[n]. To indicate x[n-2], we can put two 0 units in front of row vector x[n]. In order to keep these row vectors with a same number of digit units, we need to put two 0 units after row vector x[n] to indicate x[n], and put one 0 unit on both left and right side of row vector x[n] to indicate x[n-1]. In the program, I used orders [0 0 x], [0 x 0]and [x 0 0]to realize this calculation.The program is shown as follows:r=51;d=0.8*(rand(r,1)-0.5);m=0:r-1;s=2*m.*(0.8.^m);x=s+d';subplot(2,1,1)plot(m,d','r', m, s, 'g', m,x, 'b');xlabel('Time index n'); ylabel('Amplitude');legend('d[n]', 's[n]', 'x[n]');x1=[0 0 x]; x2=[0 x 0];x3=[x 0 0]y=(x1+x2+x3)/3;subplot(2,1,2);plot(m, y(1:r), 'r', m, s,'b');xlabel('Time index n'); ylabel('Amplitude');legend('y[n]', 's[n]');The figure is shown as follows:Fig 1.3.2 Figures of y[n]=1/3(x[n]+x[n-1]+x[n-2])The figure 1.3.2 shows the calculation result of the three signals’ (x[n], x[n-1] and x[n-2]) average value.ConclusionThrough finishing this project, I have been more familiar with the discrete signals. Moreover, I have understood the unit discrete signals and periodic function signals in the time and frequency domain better. At last, through simulating the average system, I could learn about the procedure and the effect of this useful system clearly, and understand the program better in operating it.。

相关主题