TÀI LIỆU HƯỚNG DẪN THỰC HÀNH TÍN HIỆU VÀ HỆ THỐNG BỘ MÔN KỸ THUẬT MÁY TÍNH

26 33 0
TÀI LIỆU HƯỚNG DẪN THỰC HÀNH TÍN HIỆU VÀ HỆ THỐNG BỘ MÔN KỸ THUẬT MÁY TÍNH

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Thực hành Kỹ Thuật Lập Trình Thực hành Tín hiệu và Hệ thống 2022 1 ĐẠI HỌC ĐÀ NẴNG TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN TỬ VIỄN THÔNG  TÀI LIỆU HƯỚNG DẪN THỰC HÀNH TÍN HIỆU VÀ HỆ THỐNG BỘ MÔN KỸ TH[.]

Thực hành Tín hiệu Hệ thống 2022 ĐẠI HỌC ĐÀ NẴNG TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN TỬ - VIỄN THÔNG  TÀI LIỆU HƯỚNG DẪN THỰC HÀNH TÍN HIỆU VÀ HỆ THỐNG BỘ MƠN KỸ THUẬT MÁY TÍNH Biên soạn : ThS TRẦN VĂN LÍC Đà Nẵng, năm 2022 Thực hành Tín hiệu Hệ thống 2022 TRƯỜNG ĐẠI HỌC BÁCH KHOA CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM KHOA ĐIỆN TỬ - VIỄN THÔNG Độc lập - Tự - Hạnh phúc    NỘI QUY PHÒNG THÍ NGHIỆM SINH VIÊN THỰC HÀNH, THÍ NGHIỆM TẠI PHÒNG THÍ NGHIỆM PHẢI TUÂN THEO CÁC ĐIỀU QUY ĐỊNH SAU ĐÂY : Trang phục theo quy định chung nhà trường Vào phòng TN theo lịch, quy định; Phải chuẩn bị nội dung thực hành, thí nghiệm đầy đủ Cấm hút thuốc, khơng có men bia rượu, cấm đùa giỡn, khơng lại lộn xộn, làm ồn gây trật tự ; Không xả rác Tuân thủ nghiêm quy định an toàn: Lao động, sử dụng điện, sử dụng thiết bị - dụng cụ an toàn chống cháy nổ Khi có cố an tồn điện, phải nhanh chóng cắt điện Cấm tự ý sử dụng, tháo gỡ, di chuyển mang khỏi phòng trang thiết bị, dụng cụ, vật tư phòng TN Giữ gìn tốt tài sản phòng TN; Nếu làm hỏng, làm phải bồi thường Sau thực hành, thí nghiệm xong phải tắt máy tính xếp bàn ghế gọn gàng trước ký điểm danh Mọi mát hỏng hóc xảy q trình làm thực hành, thí nghiệm sinh viên không tuân thủ theo quy định nêu nhóm sinh viên thực hành, thí nghiệm phải chịu hoàn toàn trách nhiệm Thực hành Tín hiệu Hệ thống 2022 GIỚI THIỆU HỌC PHẦN MÃ HỌC PHẦN: TÊN HỌC PHẦN: SỐ TÍN CHỈ: 1 Mục tiêu: - Trang bị cho sinh viên kiến thức thực hành phần mềm Matlab mơ tả, phân tích xử lý tín hiệu, xây dựng mơ hình mơ tả hệ tuyến tính, tạo sở cho học phần khác chương trình đào tạo ngành kỹ thuật - Sinh viên có phương pháp mô tả giải toán kỹ thuật phần mềm Matlab dựa cách tiếp cận hệ thống, độc lập bổ sung cho cách tiếp cận vật lý-hóa học Kết mong đợi: Sau hoàn thành học phần này, yêu cầu sinh viên có khả năng: - Sử dụng phần mềm Matlab để phân tích tính chất tín hiệu hệ thống miền thời gian miền tần số - Thông qua phần mềm MATLAB, trình bày giải thích ý nghĩa phép biến đổi Fourier liên tục/không liên tục, áp dụng chúng phép phân tích, xử lý tín hiệu Phương pháp học tập nhiệm vụ sinh viên - Sinh viên thực thực hành mẫu Lab đầu, sau thực tập cuối Lab tích cực thực hành MATLAB (tự làm nhà có hướng dẫn phòng máy), bám theo yêu cầu kết mong đợi - Sinh viên thực theo nhóm tự chọn (Tối đa sinh viên/ nhóm) - Sinh viên thực tổng cộng LAB nhà LAB phòng máy (1 tuần /1 bài) - Tuần học cuối (tuần học thứ 5), sinh viên có mặt theo lịch để nộp báo cáo bảo vệ thực hành Thực hành Tín hiệu Hệ thống 2022 Đánh giá kết quả: - Sinh viên phải tham gia đầy đủ buổi thí nghiệm theo lịch phòng đào tạo nghỉ q ½ số buổi thí nghiệm trở lên khơng bảo vệ - Sinh viên phải tìm hiểu đọc trước LAB trước buổi thực hành phịng máy - Sinh viên phải hồn tất Lab theo yêu cầu o Chuyên cần: 10% o Bài tập thực hành lớp: 60% o Báo cáo + Bảo vệ 30% Giảng viên phụ trách: Họ tên Trần Văn Líc Điện thoại 070.614.5815 Email tvlic@dut.udn.vn Phịng làm việc Phịng TN Mơ - C119 Thực hành Tín hiệu Hệ thống 2022 TÀI LIỆU HỌC TẬP • Tài liệu hướng dẫn thực hành (Tham khảo Lab từ Trường EASTERN MEDITERRANEAN UNIVERSITY) • Phần mềm MATLAB • Sách tham khảo: Sundararajan, D.: Practical approach to signals and systems John Wiley & Son, 2008 Edward A Lee, Pravin Varaiya: Structure and Interpretation of Signals and Systems Addison-Wesley, 2003 Hwei P Hsu: SCHAUM'S OUTLINES OF Theory and Problems of Signals and Systems McGraw-Hill, 1995 Thực hành Tín hiệu Hệ thống 2022 NỘI DUNG Lab 1: Introduction to Matlab Lab 2: Some Fundamental Properties of Signals Lab 3: Some Fundamental Properties of Systems Lab 4: The Convolution Sum and integral Lab 5: Diferential Equations Lab 6: Fourier Series and Fourier Transform Representation EENG226 /INFE226 Labsheet#1 EENG/INFE 226 SIGNALS AND SYSTEMS LAB INTRODUCTION TO MATLAB General View MATLAB is a high-level programming language that has been used extensively to solve complex engineering problems MATLAB works with three types of windows on your computer screen These are the Command window, the Figure window and the Editor window The Figure window only pops up whenever you plot something The Editor window is used for writing and editing MATLAB programs (called M-files) and can be invoked in Windows from the pulldown menu after selecting File | New | M-file The command window is the main window in which you communicate with the MATLAB interpreter The MATLAB interpreter displays a command >> indicating that it is ready to accept commands from you You can use the command window as a calculator, or you can use it to call other MATLAB programs (M-files) Say you want to evaluate the expression c where a=1.2, b=2.3, c=4.5 and d=4 Then in the command window, type: >> >> >> >> >> a = 1.2; b=2.3; c=4.5; d=4; a^3+sqrt(b*d)-4*c ans = -13.2388 Note the semicolon after each variable assignment If you omit the semicolon, then MATLAB echoes back on the screen the variable value Arithmetic Operations There are four different arithmetic operators: + Addition − Subtraction * Multiplication / Division (for matrices it also means inversion) There are also three other operators that operate on an element by element basis: * Multiplication of two vectors, element by element / Division of two vectors, element-wise ^ Raise all the elements of a vector to a power >> X=[1,3,4] >> Y=[4,5,6] >> X+Y ans= 10 Prepared By: Alaa Eleyan EENG226 /INFE226 Labsheet#1 For the vectors X and Y the operator + adds the elements of the vectors, one by one, assuming that the two vectors have the same dimension In the above example, both vectors had the dimension × 3, i.e., one row with three columns An error will occur if you try to add a × vector to a × vector The same applies for matrices To compute the dot product of two vectors, you can use the multiplication operator * For the above example, it is: >> X*Y’ ans = 43 Note the single quote after Y The single quote denotes the transpose of a matrix or a vector To compute an element by element multiplication of two vectors (or two arrays), you can use the * operator: >> X.*Y ans = 15 24 That is, X.*Y means [1×4, 3×5, 4×6] = [4 15 24] The ‘.*’ operator is used very often (and is highly recommended) because it is executed much faster compared to the code that uses for loops Complex Numbers MATLAB also supports complex numbers The imaginary number is denoted with the symbol i or j, assuming that you did not use these symbols anywhere in your program (that is very important!) Try the following: >> >> >> >> >> >> z=3 + 4i conj(z) angle(z) real(z) imag(z) abs(z) % % % % % computes computes computes computes computes the the the the the conjugate of z phase of z real part of z imaginary part of z magnitude of z You can also define the imaginary number with any other variables you like Try the following: >> img=sqrt(-1) >> z=3+4*img >> exp(pi*img) Array Indexing In MATLAB, all arrays (vectors) are indexed starting with 1, i.e., y(1) is the first element of the array y Note that the arrays are indexed using parenthesis (.) and not square brackets [.] as in C/C++ To create an array having as elements the integers through 6, just enter: Prepared By: Alaa Eleyan EENG226 /INFE226 Labsheet#1 >> x=[1,2,3,4,5,6] Alternatively, you can use the : notation, >> x=1:6 The : notation above creates a vector starting from to 6, in steps of If you want to create a vector from to in steps of say 2, then type: >> x=1:2:6 Ans = Extracting or inserting numbers in a vector can be done very easily To concatenate an array, you can use the [] operator, as shown in the example below: >> x=[1:3 100:110] To access a subset of the array, try the following: >> x(3:7) >> length(x) % gives the size of the array or vector >> x(2:2:length(x)) Allocating Memory You can allocate memory for one-dimensional arrays (vectors) using the zeros command The following command allocates memory for a 100-dimensional array: >> Y=zeros(100,1); >> Y(30) ans = Similarly, you can allocate memory for two-dimensional arrays (matrices) The command >> Y=zeros(4,5) defines a X matrix Similar to the zeros command, you can use the command ones to define a vector containing all ones, >> Y=ones(1,5) ans= 1 1 Prepared By: Alaa Eleyan EENG226 /INFE226 Labsheet#1 Special Characters and Functions Some common special characters used in MATLAB are given below: Symbol pi sqrt ˆ abs NaN Inf ; % ’ Meaning π(3.14 ) indicates square root e.g., sqrt(4)=2 indicates power(e.g., 3ˆ2=9) Absolute value | | e.g., abs(-3)=3 Not-a-number, obtained when comparing mathematically undefined operations, such as 0/0 Represents +∞ Indicates the end of a row in a matrix It is also used to suppress printing on the screen (echo off) Denotes a comment Anything to the right of % is ignored by the MATLAB interpreter and is considered as comments Denotes transpose of a vector or matrix It’s also used to define strings, e.g.,str1=’DSP’; Some special functions are given below: length(x) - gives the dimension of the array x find - Finds indices of nonzero elements >> x=1:10; >> length(x) ans = 10 The function find returns the indices of the vector X that are non-zero For example, I= find(X>100), finds all the indices of X when X is greater than 100 So for the above >> find(x> 4) ans = 10 Plotting You can plot arrays using MATLAB’s function plot The function plot(.) is used to generate line plots The function stem(.) is used to generate “picket-fence” type of plots >> x=1:20; Prepared By: Alaa Eleyan EENG226 /INFE226 Labsheet#2 EENG/INFE 226 SIGNALS AND SYSTEMS LAB SOME FUNDAMENTAL PROPERTIES OF SIGNALS 1) Consider the discrete-time signal ⎛ 2πMn ⎞ x M [n] = sin ⎜ ⎟ ⎝ N ⎠ and assume N=12 For M=4, 5, and 10, plot x M [n] on the interval ≤ n ≤ N − Use stem to create your plots, and be sure to appropriately label your axes What is the fundamental period of each signal? Answer: N=12; n=[0:2*N-1]; M=4 x_M=sin((2*pi*M*n)/N); figure(1) stem(n,x_M,'filled') title('x[n]=sin(2*pi*M*n/N)') xlabel('Time') ylabel('Amplitude') % Discrete time interval % M=5,7,10 % Discrete time signal % open new figure % draw the signal % title of Discrete time signal % Name of x direction % Name of y direction x[n]=sin(2*pi*M*n/N) 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 Amplitude Amplitude x[n]=sin(2*pi*M*n/N) -0.2 -0.2 -0.4 -0.4 -0.6 -0.6 -0.8 -0.8 -1 10 15 20 -1 25 10 Time M=4 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 Amplitude Amplitude -0.2 -0.4 -0.6 -0.6 -0.8 -0.8 10 20 25 -0.2 -0.4 25 x[n]=sin(2*pi*M*n/N) 20 M=5 x[n]=sin(2*pi*M*n/N) -1 15 Time 15 20 -1 25 10 Time 15 Time M=7 M=10 Prepared by: Alaa Eleyan EENG226 /INFE226 Labsheet#2 2) Now consider the following signals: ⎛ 2n ⎞ ⎛ 3n ⎞ x [n] = cos⎜ ⎟ + cos⎜ ⎟ ⎝N⎠ ⎝N⎠ ⎛ 2πn ⎞ ⎛ 5πn ⎞ x3 [n] = cos⎜ ⎟ + sin ⎜ ⎟ ⎝ N ⎠ ⎝ 2N ⎠ Assume N=6 for each signal Determine whether or not each signal periodic If a signal is periodic, plot the signal for two periods, starting at n=0 Plot the signal for ≤ n ≤ N and explain why it is periodic or not Remember to use stem and to appropriately label your axes x2[n] Answer: N=6; -2 n=[0:7*N]; -4 x2=2*cos(2*n/N)+cos(3*n/N); x3=cos(2*pi*n/N)+3*sin(5*(pi/2)*n/N); subplot(2,1,1),stem(n,x2) title('x2[n]') subplot(2,1,2),stem(n,x3) title('x3[n]') 10 15 20 25 30 35 40 45 25 30 35 40 45 x3[n] -2 -4 10 15 20 3) a) Define a MATLAB vector nx to be the time indices − ≤ n ≤ and the MATLAB vector x to be the values of the signal x[n] is given by ⎧2,Kn = 0, ⎪1,Kn = 2, ⎪⎪ x[n] = ⎨−1,Kn = 3, ⎪3,Kn = 4, ⎪ ⎪⎩0,Kotherwise If you have defined these vectors correctly, you should be able to plot this discrete time sequence by typing stem(nx,x) x[n] 2.5 Answer: nx=[-3:7]; x=[0 0 -1 0 0]; stem(nx,x,'filled') title('x[n]') xlabel('n') ylabel('x[n]') x[n] 1.5 0.5 -0.5 -1 -3 -2 -1 n Prepared by: Alaa Eleyan EENG226 /INFE226 Labsheet#2 b) For this part, you will define MATLAB vectors y1 through y4 to represent the following discrete-time signals: y [n ] = x [n − ] , y [ n ] = x [n − ] , y [n ] = x [ − n ] , y [ n ] = x [− n + ] to this, you should define y1 through y4 to be equal to x The key is to define correctly the corresponding index vectors ny1 through ny4 First, you should figure out how the index of a given sample of x[n] changes when transforming to y i [n] The index vectors need not span the same of indices as nx, but they should all be at least 11 samples long and include the indices of all nonzero samples of associated signal Answer: n=[-3:7]; x=[2 -1 0]; nx=[0 0 x 0]; ny1=n+2; ny2=n-1; ny3=-n; ny4=-n+1; x[n-2] x[n-2] figure(1) -1 -1 subplot(2,1,1),stem(ny1,nx,'filled') xlabel('time') ylabel('x[n-2]') title('x[n-2]') time x[n+1] -3 -2 -1 time x[n+1] subplot(2,1,2),stem(ny2,nx,'filled') xlabel('time') ylabel('x[n+1]') title('x[n+1]') -1 -4 figure(2) x[-n] x[-n] subplot(2,1,1),stem(ny3,nx,'filled') xlabel('time') ylabel('x[-n]') title('x[-n]') -1 -7 subplot(2,1,2),stem(ny4,nx,'filled') xlabel('time') ylabel('x[-n+1]') title('x[-n+1]') -6 -5 -4 -3 -2 time x[-n+1] -1 -5 -4 -3 -2 -1 time x[-n+1] -1 -6 Prepared by: Alaa Eleyan Name: …………… ID No.:………………… EENG/INFE 226 SIGNALS AND SYSTEMS LAB SOME FUNDAMENTAL PROPERTIES OF SYSTEMS Objective The objective of this experiment is to introduce using MATLAB to define an LTI system and determine on its main features, such as; linearity, causality stability invertibility and time variance This is achieved by examining the performance of the system for particular inputs that will show those characteristics Linearity: A system is linear if superposition holds Specifically, a linear system must satisfy the two properties:  Additive: the response to x1(t)+x2(t) is y1(t) + y2(t)  Scaling: the response to ax1(t) is ay1(t) where aC  Combined: ax1(t)+bx2(t)  ay1(t) + by2(t) Exercise The system is [ ] n( [ ]) is not linear Show that it violates linearity by giving a counter example A good example is the set of signals [ ] [ ] [ ] [ ] Figure Exercise Result Write a MATLAB code to demonstrate this example This can be done as follows:      Define the domain of the two signals to be from -3 to and save it as a vector n Define the signal x1 as a vector of the values [0 0 0 0] Define the signal x2 =2x1 Evaluate the output corresponding to the x1 input, and label it as y1 Evaluate the output corresponding to the x2 input, and label it as y2 On the same graph window, plot the signals x1, x2, y1 and y2 using the commands (subplot) and (stem) Your results should be as depicted in Figure Q: Is y2 equal to 2y1, what is your coment? ………………………………………………………………………………………………………………………… Causality A causal system is a system where the current output depends on past/current inputs but not future inputs Exercise The system [ ] [ ] [ ] is not causal Use the input signal [ ] [ ] to show this, as follows:      Define the time (sample) interval to be between -6 and 9, and label it as n Define the signal x[n]=U[n] as an array with the values for n=0 Figure Exercise Result and label it as x Define the signal x[n+1] =U[n+1] as an array of zeros for n=-1 and label it as x_shift Define the output signal y[n] as x[n]+x[n+1] On the same window, plot the signals x[n], x[n+1] and y[n] using the commands (subplot) and (stem).You should have a plot identical to the one shown in Figure Q: What is your comment about the system causality? ………………………………………………………………………………………………………………………… Stability For a stable system, if an input signal is bounded, then the output signal must also be bounded Exercise The system y[n]=log(x[n]) is not stable because the (log) function goes to minus infinity at the input Write a MATLAB code to illustrate this Proceed as follows:   Define the domain vector as n ranging between -2 and Define the input signal x as a vector of the values: 1, 2, 0, 3, and   Declare the output vector as y= log(x) using the(log) function Using stem and subplot commands, plot the input signal x[n] and the corresponding output signal y[n] The result should appear as shown in Figure Q: Comment on your result How does this result indicate that the system is unstable? ………………………………………………………………………………………………………………………… Invertible and Inverse Systems Invertible System A system is invertible if the input signal can be uniquely determined from knowledge of the output signal Therefore, invertibility requires the system to be one-to-one and generate a distinct output for each input Exercise The system y[n] = sin(2πx[n]) where x[n]=[0 0] is not invertible Illustrate this by showing that the system is not one-to-one As follows:     Define a vector of n values of 0,1,2,3,4 and and label it as n Define x[n] as a vector of the values 0,1,2,3,4 and Define the output as y[n] = sin(2πx[n]) Plot x[n] and y[n] using the commands (stem) and (subplot) Your result should be as shown in Figure4 Q: Comment on the result justifying the claim that the system in not invertible ……………………………………………………………………………………………………… …………………………………………………………………………………………………… Figure Exercise Result Figure Exercise Result Students name: ……… ID No.:…………… EENG/INFE 226 SIGNALS AND SYSTEMS LAB The Convolution Sum and Integral Objective The objective of this experiment is to introduce using MATLAB to perform discrete time convolution, and to simulate continuous time convolution for some common signals Convolution: The convolution of the signals x(t) and h(t) is mathematically defined as: ( ) ( ) ( ) ∫ ( ) ( ) And for the discrete time signals x[n] and h[n], it is defined as: [ ] [ ] [ ] ∑ [ ] [ ] Exercise Use MATLAB to evaluate the convolution of x[n] with itself, where [ ] { } Procedure:       Define the signal x as a vector of values [ 1 1 1], using the (ones) command Use the (conv) function to evaluate the convolution of x with itself, and name it as y Define the index vector n to range from to 10 Using the function (stem), plot y versus n Label the vertical and horizontal axes as (Amplitude) and (Time), respectively Title the figure as (y[n]) Q: Comment on the relationship between the length of y[n] and x[n] ………………………………………………………………………………………………………………………… Prepared by: Mahmoud Nazzal & Qadri Mayyala Exercise I Consider the discrete time signals: [ ] { } [ ] { }   Define the signal x as a vector of values [0 5] Define the signal u as a vector of values [ 1 1 1], using the (ones) command  Use the function (conv) function to evaluate the convolution of x with u, and name it as y Define the index vector n to range from to 10 Using the function (stem), plot y versus n Label the vertical and horizontal axes as (Amplitude) and (Time), respectively Title the figure as (y[n])     Repeat part I using u[n+5] instead of u[n] II Q: Comment on the relationship between y[n] in part I, and y[n] of part II …………………………………………………………………………………………………………………… Exercise In this part, continuous time convolution will be simulated in the discrete case Consider the continuous time signals x(t) and h(t) Generate these functions using a time step of 0.1 ( ) { } ( ) { } Procedure:    Define the domain of x as a vector ranging from to 5, with a time step of 0.1 Name it as tx Define the domain of h as a vector ranging from to 7, with a time step of 0.1 Name it as th Define the signal x as a vector of ones over the index vector tx, using the (ones),(length) command, Prepared by: Mahmoud Nazzal & Qadri Mayyala       Define the signal h as a vector of ones of the index vector th, using the (ones) ),(length) command Declare the total time length of the convolution to range from to 12, with a 0.1 step Name it as ty Use the function (conv) function to evaluate the convolution of x(t) with h(t), and name it as y Hint: Don’t forget to multiply the conv by Ts=0.1 (Ts step time) Using the function (stem), plot y versus ny Label the vertical and horizontal axes as (Amplitude) and (Time), respectively Title the figure as (y(t)) Q: Comment on the relationship between the time length of y(t)and that of x(t) and h(t) ………………………………………………………………………………………………………………………… The RESULTS: y[n] y[n] 15 10 Amp Amplitude 0 Time 10 Time 10 Exercise Part -1 Exercise y(t) y[n]=x[n] * u[n+5] 4.5 15 3.5 Amp Amp 10 2.5 1.5 0.5 -5 -4 -3 -2 -1 Time Exercise Part -2 5 10 11 12 Time Exercise Prepared by: Mahmoud Nazzal & Qadri Mayyala ... Email tvlic@dut.udn.vn Phịng làm việc Phịng TN Mơ - C119 Thực hành Tín hiệu Hệ thống 2022 TÀI LIỆU HỌC TẬP • Tài liệu hướng dẫn thực hành (Tham khảo Lab từ Trường EASTERN MEDITERRANEAN UNIVERSITY)... tích, xử lý tín hiệu Phương pháp học tập nhiệm vụ sinh viên - Sinh viên thực thực hành mẫu Lab đầu, sau thực tập cuối Lab tích cực thực hành MATLAB (tự làm nhà có hướng dẫn phịng máy) , bám theo... quy định nêu nhóm sinh viên thực hành, thí nghiệm phải chịu hồn tồn trách nhiệm Thực hành Tín hiệu Hệ thống 2022 GIỚI THIỆU HỌC PHẦN MÃ HỌC PHẦN: TÊN HỌC PHẦN: SỐ TÍN CHỈ: 1 Mục tiêu: - Trang

Ngày đăng: 20/11/2022, 11:45

Tài liệu cùng người dùng

Tài liệu liên quan