BÁO cáo THÍ NGHIỆM bài môn xử lí số tín hiệu

23 17 0
BÁO cáo THÍ NGHIỆM bài môn xử lí số tín hiệu

Đ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

ĐẠI HỌC QUỐC GIA TP HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA BÁO CÁO THÍ NGHIỆM BÀI Mơn: Xử lí số tín hiệu GVDH :Huỳnh Văn Phận Nhóm Nguyễn Quang Huy - 1812400 Hồ Anh Khoa - 1812643 Nguyễn Hồng Long - 1812899 Ngày thí nghiệm: 02/10/2021  Thực hành 1: Viết file-M thực chương trình lưu với tên Bai1_NHOMx_PlotGraph.m Yêu cầu 1: Ghi nhớ lệnh matlab chương trình Bài làm x = 0:pi/20:2*pi; % Define vector x from to 2pi with step size pi/100 y = sin(x); % Define vector y subplot(1,2,1); % Create a graph with two sub-graphs in row column and with subplot position plot(x,y,'b-'); % Plot x versus y axis([0 2*pi -1 1]); xlabel('x (pi)'); ylabel('y=sin(x)'); %Label of x-axis and y-axis title('Graph of Continuous Sine from to 2pi'); %Title of graph subplot(1,2,2);stem(x,y,'r-') %Plot p versus q with subplot position axis([0 2*pi -1 1]); xlabel('x (pi)'); ylabel('y=sin(x)'); %Label of p-axis and q-axis title('Graph of Discrete Sine from to 2pi'); %Title of graph  Thực hành 2: Viết file-M thực chương trình lưu với tên Bai1_NHOMx_DFT.m Bài làm clc; close all; xn = [1, 2, 3, 4, 5, 6]; L = length(xn); %find the length of the sequence Xk = zeros(1,L); %initialize an array of same size as that %DFT of the sequence for k = 0:L-1 for n = 0:L-1 Xk(k+1) = Xk(k+1) + xn(n+1)*exp(-1j*2*pi*k*n/L); end end % Using FFT Matlab Xk_2 = fft(xn,L); %Plotting input sequence t=0:L-1; subplot(1,3,1); stem(t,xn); ylabel ('Amplitude'); xlabel ('Time Index'); title('Input Sequence'); t=0:L-1; % Find the magnitudes of individual DFT points Xk_magnitude = abs(Xk); Xk_2_magnitude = abs(Xk_2); % plot the magnitude response subplot(1,3,2); stem(t,Xk_magnitude,'bo-'); hold on; stem(t,Xk_2_magnitude,'r* '); hold on; ylabel ('Amplitude'); xlabel ('K'); title('Magnitude Response'); % Find the phases of individual DFT points Xk_phase = angle(Xk); Xk_2_phase = angle(Xk_2); % plot the magnitude sequence subplot(1,3,3); stem(t,Xk_phase,'bo-'); hold on; stem(t,Xk_2_phase,'r* '); hold on; ylabel ('Phase'); xlabel ('K'); title ('Phase Response'); legend('Computing', 'fft Matlab');  Thực hành 3: Viết chương trình thực biến đổi IDFT chuỗi X k   10, 2  2i, 2, 2  2i theo cách Lưu lại với tên Bai1_NHOMx_IDFT.m Bài làm clc; clear all; Xk = [10,-2+2j,-2,-2-2j]; L = length(Xk); %find the length of the sequence xn = zeros(1,L); %initialize an array of same size as that of input sequence %DFT of the sequence for k = 0:L-1 for n = 0:L-1 xn(k+1)=xn(k+1)+((1/L)*(Xk(n+1)*exp((1i*2*pi*k*n)/L))); end end % Using IDFT Matlab xn_2 = ifft(Xk,L); %Plotting input sequence t=0:L-1; subplot(1,3,1); Xk_magnitude = abs(Xk); stem(t,Xk_magnitude); ylabel ('Amplitude'); xlabel ('Time Index'); title('Input Sequence'); t=0:L-1; % Find the magnitudes of individual IDFT points xn_magnitude = abs(xn); xn_2_magnitude = abs(xn_2); % Plot the magnitude response subplot(1,3,2); stem(t,xn_magnitude,'bo-'); hold on; stem(t,xn_2_magnitude,'r* '); hold on; ylabel ('Amplitude'); xlabel ('K'); title('Magnitude Response'); %Find the phases of individual IDFT points xn_phase = angle(xn); xn_2_phase = angle(xn_2) %Plot the magnitude sequence subplot(1,3,3); stem(t,xn_phase,'bo-'); hold on; stem(t,xn_2_phase,'r* '); hold on; ylabel ('Phase'); xlabel ('K'); title ('Phase Response'); legend('Computing', 'idft Matlab');  Thực hành 4: Viết file-M tìm ngõ y(n) hệ thống nhân với ngõ vào x(n) = [1, 3, 5, 3, 6, 3] đáp ứng xung h(n) = [1, 4, 7, 2, 8] theo cách, lưu với tên bai1_NHOMx_conv.m Bài làm xn = [1, 3, 5, 3, 6, 3]; hn = [1, 4, 7, 2, 8]; Lx = length(xn); N = length(hn); M = N - 1; Ly = Lx + M; yn = zeros(1, Ly); for n = : Ly-1 for m = max(0,n-Lx + 1):min(n,M) yn(n+1) = yn(n+1) + hn(m+1) * xn(n-m+1); end end yn xn = [1, 3, 5, 3, 6, 3]; hn = [1, 4, 7, 2, 8];  Thực hành 5: Viết file-M vẽ đáp ứng tần số hệ thống có hàm truyền theo cách: i) tính tốn đáp ứng tần số ii) sử dụng hàm Matlab, lưu với tên Bai1_NHOMx_freqz.m Yêu cầu: Vẽ đáp ứng miền tần số Matlab lọc có hàm truyền sau 1 0.4z 1 H z khoảng     1 0.8z 1    Bài làm Ta có đáp ứng tần số H     2e j với   2 f / f s 1 0.8e j % Sket frequency response of filter - way omega = 0:pi/10:pi; H = (5 + 2*exp(-1j*omega))./(1-0.8*exp(-1j*omega)); H_manitude = abs(H); H_phase = angle(H); subplot(2,2,1); plot(omega,H_manitude); title('Amplitude Response'); subplot(2,2,2); plot(omega,H_phase); title('Phase Response'); % Sket frequency response of filter - way a = [1, -0.8]; b = [5, 2]; [H_matlab, w] = freqz(b,a); H_matlab_manitude = abs(H_matlab); H_matlab_phase = angle(H_matlab); subplot(2,2,3); plot(omega,H_manitude); title('Amplitude Response'); subplot(2,2,4); plot(omega,H_phase); title('Phase Response');  Thực hành 6: Viết chương trình Matlab thực yêu cầu sau: Tạo chu kỳ mẫu tín hiệu s1  cos2 f1t với f  400 Hz, tần số lẫy mẫu 8000 Hz 1  sTạo mẫu tín hiệu 1 T  t   3T  0 elsewhere  Tạo tín hiệu sinc s4  sinc 2 f t  tần số 500 Hz 0.5 lấy mẫu với 20 chu kỳ T với f  40 Hz,  t  (s) lấy mẫu Bài làm Tạo chu kỳ mẫu tín hiệu s1  cos2 f1t với f1  400 Hz, tần số lẫy mẫu 8000 Hz  clc clear % Signal Genergating Fs = 8e3; % Sampling frequency kHz Ts = 1/Fs; F_xt = 300; % Frequency of signal 300 Hz t = : Ts : 5*Ts; s1 = cos(2 * pi * F_xt * t); N = length(s1); % DFT length = signal length Xk = fft(s1, N); % DFT of signal Xk_Man = abs(Xk); Xk_Pha = angle(Xk); %% Signal plot figure(1) subplot(1,2,1) hold on plot(t, s1); xlabel('Time (sec)'); ylabel('Amplitude'); subplot(1,2,2) hold on plot(0:N-1, s1); xlabel('Sampling index - n'); ylabel('Amplitude'); %% Spectrum plot figure(2) subplot(1,2,1) stem((0:N/2-1)*Fs/N, Xk_Man(1:N/2) / N); xlabel('Frequency (Hz)'); ylabel('Amplitude'); title('Nhom 1'); subplot(1,2,2); plot((0:N/2-1)*Fs/N, Xk_Pha(1:N/2) ); s Tạo mẫu tín hiệu  1 T  t  3T lấy mẫu với 20 chu kỳ T  0 elsewhere clc clear % Signal Genergating Fs = 1e3; % Sampling frequency kHz Ts = 1/Fs; % Sampling period F_xt = 300; % Frequency of signal 300 Hz T_sim = 0.02; % Signal duration in seconds 50 ms t = : Ts : T_sim - Ts; s2 = [0 0 0 1 1 1 1 1 0 0 0]; N = length(s2); % DFT length = signal length Xk = fft(s2, N); % DFT of signal Xk_Man = abs(Xk); Xk_Pha = angle(Xk); %% Signal plot figure(1) subplot(1,2,1) grid on hold on plot(t, s2); xlabel('Time (sec)'); ylabel('Amplitude'); subplot(1,2,2) grid on hold on plot(0:N-1, s2); xlabel('Sampling index - n'); ylabel('Amplitude'); %% Spectrum plot figure(2) subplot(1,2,1) stem((0:N/2-1)*Fs/N, Xk_Man(1:N/2) / N); grid on xlabel('Frequency (Hz)'); ylabel('Amplitude'); subplot(1,2,2) plot((0:N/2-1)*Fs/N, Xk_Pha(1:N/2) ); grid on xlabel('Frequency (Hz)'); ylabel('Phase'); Tạo tín hiệu sinc số 500 Hz s4  sinc2 f t  0.5 với f4  40 clc clear % Signal Genergating Fs = 5e2; % Sampling frequency 500hz Ts = 1/Fs; % Sampling period F_xt = 40; % Frequency of signal 40 Hz T_sim = 1; t = : Ts : T_sim - Ts; xn = sinc(2 * pi * F_xt * (t-0.5)); N = length(xn); % DFT length = signal length Xk = fft(xn, N); % DFT of signal Xk_Man = abs(Xk); Xk_Pha = angle(Xk); %% Signal plot figure(1) subplot(1,2,1) hold on plot(t, xn); xlabel('Time (sec)'); ylabel('Amplitude'); subplot(1,2,2) hold on plot(0:N-1, xn); xlabel('Sampling index - n'); ylabel('Amplitude'); %% Spectrum plot figure(2) subplot(1,2,1) stem((0:N/2-1)*Fs/N, Xk_Man(1:N/2) / N); xlabel('Frequency (Hz)'); ylabel('bien do'); subplot(1,2,2) plot((0:N/2-1)*Fs/N, Xk_Pha(1:N/2) ); Hz,  t  (s) lấy mẫu tần  Thực hành 7: Thực việc thiết kế lọc FIR chắn dải với thông số ví dụ Lấy hệ số viết chương trình vẽ đáp ứng tần số lọc Lưu lại với tên BAI_1_NHOMx_bs2700_freqz Sử dụng hàm semilogy thay cho plot đưa nhận xét khác biệt Bài làm - Nhập thông số hình: Columns through -0.0004 0.0007 -0.0003 -0.0002 -0.0000 0.0002 0.0005 -0.0018 -0.0045 0.0036 0.0021 -0.0075 0.0061 0.0022 0.0016 -0.0091 0.0073 0.0006 -0.0050 0.0027 -0.0072 0.0010 0.0150 -0.0226 0.0048 0.0285 0.0411 -0.0632 0.0221 0.0504 -0.0821 0.0337 0.0445 0.0520 0.9001 0.0520 0.0445 -0.0953 -0.0821 0.0504 0.0221 -0.0632 0.0411 0.0120 0.0048 -0.0226 0.0150 0.0010 -0.0072 0.0032 -0.0050 0.0006 0.0073 -0.0091 0.0016 0.0079 0.0061 -0.0075 0.0021 0.0036 -0.0045 0.0014 0.0005 0.0002 -0.0000 -0.0002 -0.0003 0.0007 Columns through 16 0.0015 0.0014 Columns 17 through 24 -0.0095 0.0079 Columns 25 through 32 -0.0000 0.0032 Columns 33 through 40 -0.0421 0.0120 Columns 41 through 48 0.0542 -0.0953 Columns 49 through 56 0.0542 0.0337 Columns 57 through 64 -0.0421 0.0285 Columns 65 through 72 -0.0000 0.0027 Columns 73 through 80 -0.0095 0.0022 Columns 81 through 88 0.0015 Column 89 -0.0004 -0.0018 - Đáp ứng tần số hàm plot: - Đáp ứng tần số hàm semilogy:  Thực hành 8: Thực việc thiết kế lọc FIR chắn dải với thông số ví dụ Lấy hệ số viết chương trình vẽ đáp ứng tần số lọc Lưu lại với tên BAI_1_NHOMx_bs2700_freqz Sử dụng hàm semilogy thay cho plot Bài làm b = filt2.tf.num; a = filt2.tf.den; [H_matlab,w]=freqz(b,a); H_matlab_manitude= abs (H_matlab); H_matlab_phase = angle(H_matlab); plot(w,H_matlab_manitude); title("dap ung tan so ham plot"); - Đáp ứng tần số hàm plot: b = filt2.tf.num; a = filt2.tf.den; [H_matlab,w]=freqz(b,a); H_matlab_manitude= abs (H_matlab); H_matlab_phase = angle(H_matlab); semilogy (w,H_matlab_manitude); title("dap ung tan so ham semilogy"); - Đáp ứng tần số hàm semilogy:  Thực hành 9: Thực chương trình thiết kế lọc thông dải đa dải vẽ đáp ứng tần số với yêu cầu ví dụ Bài làm - Bộ lọc FIR: %multibandfir63.m: Multiband FIR filter with 63 coefficients f = [0 0.1 0.12 0.18 0.2 0.3 0.32 0.38 0.4 1]; m = [0 1 0 1 0]; n = 63; cof = remez(n-1,f,m); % frequency response with 256 points [h w] = freqz(cof,1,256); % plot magnitude of the filter plot(f * 5000,m, 'b'); hold on; - Bộ lọc IIR: %multibandiir63.m: Multiband IIR filter with 63 coefficients f = [0 0.1 0.12 0.18 0.2 0.3 0.32 0.38 0.4 1]; m = [0 1 0 1 0]; n = 63; [num, den] = yulewalk(n-1,f,m); % frequency response with 256 points [h w] = freqz(num,den,256); % plot magnitude of the filter plot(f * 5000,m, 'b'); hold on; plot(w/pi*5000,abs(h), 'r-.'); grid on  Thực hành 10: Thiết kế lọc FIR chắn đa dải 1000-1500 2500-3000, có bậc 62, tần số lấy mẫu 10 kHz Sau vẽ đáp ứng tần số lọc Bài làm Dải Tần số (Hz) Tần số chuẩn hóa f/FN Biên độ – 1000 – 0.2 1100 – 1400 0.22 – 0.28 1500 – 2500 0.3 – 0.5 2600 – 2900 0.52 – 0.58 3000 - 5000 0.6 - 1 %multibandfir62.m: Multiband FIR filter with 62 coefficients clc; clear all; f = [0 0.2 0.22 0.28 0.3 0.5 0.52 0.58 0.6 1]; m = [1 0 1 0 1]; n = 62; cof = remez(n-1,f,m); % frequency response with 256 points [h w] = freqz(cof,1,256); % plot magnitude of the filter plot(f * 5000,m, 'b'); hold on;  Thực hành 11: Thiết kế lọc IIR chắn đa dải 1000-1500 2500-3000, có bậc 62, có tần số lấy mẫu 10 kHz Sau vẽ đáp ứng tần số lọc Bài làm Dải Tần số (Hz) Tần số chuẩn hóa f/FN Biên độ – 1000 – 0.2 1100 – 1400 0.22 – 0.28 1500 – 2500 0.3 – 0.5 2600 – 2900 0.52 – 0.58 3000 - 5000 0.6 - 1 %multibandfir62.m: Multiband IIR filter with 62 coefficients clc; clear all; f = [0 0.2 0.22 0.28 0.3 0.5 0.52 0.58 0.6 1]; m = [1 0 1 0 1]; n = 62; [num, den] = yulewalk(n-1,f,m); % frequency response with 256 points [h w] = freqz(num,den,256); % plot magnitude of the filter plot(f * 5000,m, 'b'); hold on; ... Tạo chu kỳ mẫu tín hiệu s1  cos2 f1t với f  400 Hz, tần số lẫy mẫu 8000 Hz 1  sTạo mẫu tín hiệu 1 T  t   3T  0 elsewhere  Tạo tín hiệu sinc s4  sinc 2 f t  tần số 500 Hz 0.5... thông số ví dụ Lấy hệ số viết chương trình vẽ đáp ứng tần số lọc Lưu lại với tên BAI_1_NHOMx_bs2700_freqz Sử dụng hàm semilogy thay cho plot đưa nhận xét khác biệt Bài làm - Nhập thông số hình:... -0.0018 - Đáp ứng tần số hàm plot: - Đáp ứng tần số hàm semilogy:  Thực hành 8: Thực việc thiết kế lọc FIR chắn dải với thông số ví dụ Lấy hệ số viết chương trình vẽ đáp ứng tần số lọc Lưu lại với

Ngày đăng: 12/01/2022, 19:10

Hình ảnh liên quan

- Nhập thông số như hình: - BÁO cáo THÍ NGHIỆM bài môn xử lí số tín hiệu

h.

ập thông số như hình: Xem tại trang 15 của tài liệu.

Mục lục

  • Thực hành 3: Viết chương trình thực hiện biến đổi IDFT của chuỗi

  • Thực hành 4: Viết một file-M tìm ngõ ra y(n) của hệ thống nhân quả với ngõ vào x(n)

  • Thực hành 5: Viết một file-M vẽ đáp ứng tần số của hệ thống có hàm truyền trên theo 2 cách: i) tính toán đáp ứng tần số và ii) sử dụng hàm Matlab, và lưu với tên Bai1_NHOMx_freqz.m

    • Ta có đáp ứng tần số

    • 1 0.8e j

      • Thực hành 6: Viết các chương trình Matlab thực hiện các yêu cầu sau:

      • 2 Tạo mẫu tín hiệu s

      • 3 0 elsewhere

        • 3. Tạo tín hiệu sinc ở tần số 500 Hz

        • 2. Tạo mẫu tín hiệu s

        • Nhập thông số như hình:

        • Đáp ứng tần số hàm plot:

          • Đáp ứng tần số hàm plot:

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

  • Đang cập nhật ...

Tài liệu liên quan