BÀI TẬP LỚN TÍN HIỆU VÀ LỌC SỐ

100 496 0
BÀI TẬP LỚN TÍN HIỆU VÀ LỌC SỐ

Đ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

Mục Lục I Project 1:CIRCULAR INDEXING 1.1:Circular Shift and Rotations 1.2:Circular Flip 1.3:Flipping and Shift Signals II.Project 2:CIRCULAR CONVOLUTION 26 2.1:Function for Circular Convolution 2.2:More Examlies of Circular Convolution 2.3:Flipping and Shifting Signals III.Procject 3:RELATION TO LINEAR CONVOLUTION 43 3.1:Study the conv Function 3.2:Convolution as a Matrix Operation 3.3:Circular Convolution via Time Aliasing 3.4:Circular Convolution via Periodic Extension 3.5:Zero Padding 3.6:Good Outputs versus Bad Outputs IV:Project 5:HIGHT-SPEED CONVOLUTION 5.1:FFT conv Function 5.2:Crossover Point Trang 66 5.3:Compare with FIR Filtering V:Project 3:RESOLUTION 77 (Procject khác project phần trước) 3.1:Definition of Resolution 3.2:Peak Finding 3.3:Measuring Resolution *************************************** Một số hàm M-file viết là: 1: cflip.m (hàm lật vòng) 2: circonv.m (hàm chập vòng sử dụng FFT) 3: circonv1.m (hàm chập vòng sử dụng định nghĩa) 4: cirmatrix.m (hàm tạo ma trận vòng) 5: cirshift.m (hàm dịch vòng) 6: convmatrix.m (hàm tạo ma trận chập tuyến tính) 7: Mod.m 8: new_conv.m (hàm tính modulo số) (hàm chập tuyến tính sử dụng kĩ thuật over-save) 9: new_conv1.m (hàm chập tuyến tính sử dụng kĩ thuật over-add) Trang 10: new_conv2.m (hàm chập tuyến tính cho tín hiệu thực sử dụng kĩ thuật over-save) 11: peak_finding.m (hàm tìm đỉnh tín hiệu) 12: periodic_conv.m (hàm chập vòng sử dụng conv) 13: puzzle.m (M-file giải câu đố project 2) 14: resolution.m (M-file tính điểm cho cửa sổ chữ nhật theo ΔW) 15: resolution1.m (hàm tính điểm vẽ đồ thị điểm theo ΔW cho cửa sổ) 16: time_alias.m (hàm tạo dãy tuần hoàn chu kì cho trước) Trang Sinh viên:Đỗ Văn Hưởng MSSV:20081335 Đề 7: Project 1:CIRCULAR INDEXING EXERCISE 1.1:Circular Shifts and Rotations A Biến đổi DFT dãy dịch vòng cần nhân dãy gốc với véc tơ mũ phức W = Ta dung MATLAB để kiểm tra tính chất này.Ta sử dụng tín hiệu vào là: 1.Tín hiệu vào xung đơn vị:[n] Biểu diễn MATLAB:(ta lấy mẫu khoảng [0,9] Trang >> clear >> n=[0:9]; >> x=[n==0] x= 0 0 0 0 >> stem(n,x) >> title('Impulse signal') >> xlabel('n') >> ylabel('x[n]') >> %gia su l=2 N=10; l=2; W=exp(-j*2*pi/N*l*n); >> %su dung ham dich vong cirshift a=cirshift(x,l); >> fft(a) ans = Columns through 1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i + 0.9511i 1.0000 0.3090 - 0.9511i Columns through 10 -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i >> fft(x).*W Trang 0.3090 ans = Columns through 1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i + 0.9511i 1.0000 0.3090 - 0.9511i -0.8090 + 0.5878i Columns through 10 -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i Ta nhận thấy sư giống hoàn toàn fft(a) fft(x).*W Đúng nhận xét 2.Tín hiệu vào xung (pulse) clear Trang 0.3090 n=0:9; x=[n> stem(n,x); >> title('pulse signal'); >> xlabel('n') ylabel('x[n]') >> N=10; l=2; W=exp(-j*2*pi/N*l*n); %su dung ham dich vong cirshift >> a=cirshift(x,l); >> fft(a) ans = Columns through 6.0000 0.9511i -2.9271 - 0.9511i -0.8090 - 0.5878i 0.4271 + 0.5878i 0.3090 + 0.3090 - 0.9511i Columns through 10 0.4271 - 0.5878i -0.8090 + 0.5878i -2.9271 + 0.9511i >> fft(x).*W ans = Columns through Trang 6.0000 0.9511i -2.9271 - 0.9511i -0.8090 - 0.5878i 0.4271 + 0.5878i 0.3090 + 0.3090 - 0.9511i Columns through 10 0.4271 - 0.5878i -0.8090 + 0.5878i -2.9271 + 0.9511i Ta nhận thấy sư giống hoàn toàn fft(a) fft(x).*W Đúng nhận xét 3.Tín hiệu vào xung hình sin clear n=0:9; x=sin(n) Trang x= 0.4121 0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.6570 0.9894 >> stem(n,x); >> title('Sinusoids signal'); >> xlabel('n'); >> ylabel('x[n]'); >> %gia su l=2 N=10; l=2; %dịch phải W=exp(-j*2*pi/N*l*n); %vector mũ phức %su dung ham dich vong cirshift a=cirshift(x,l); >> fft(a) ans = Columns through 1.9552 1.5397 - 2.8134i 1.8290 + 2.7114i 0.6960 - 0.1292i 0.0195 0.3233i -0.2303 0.0195 + 0.3233i Columns through 10 0.6960 + 0.1292i 1.8290 - 2.7114i 1.5397 + 2.8134i >> fft(x).*W ans = Columns through Trang 1.9552 1.5397 - 2.8134i 1.8290 + 2.7114i 0.6960 - 0.1292i 0.0195 0.3233i -0.2303 - 0.0000i 0.0195 + 0.3233i Columns through 10 0.6960 + 0.1292i 1.8290 - 2.7114i 1.5397 + 2.8134i Ta nhận thấy sư giống hoàn toàn fft(a) fft(x).*W Đúng nhận xét Ngoài k=N/2 trường hợp đặc biệt.(ví dụ N=16 k=8).Khi Ta có W ==exp(-j*π )=-1 Chính DFT tín hiệu ngược dấu so với tín hiệu gốc B viết hàm tính modul (function Mod) %Đầu vào số a,b %Đầu modulo c chúng ( 0≤c=0 & a> Mod(-5,7) ans = C viết hàm dịch vòng(function cirshift) Trang 10 Nhap w2=1.04 Trang 86 Nhận thấy kết giống phần A ΔW nhỏ để đỉnh hợp lại thành giảm xuống ΔW=0.04 Tóm lại để phân biệt đỉnh ΔW ≥ 2π /L EXERCISE 3.2:Peak Finding A,B.Viết hàm Peak Finding Hàm viết MATLAB sau: %%%%%%%%%% function [a,len]=peak_finding(y,n) x=diff(abs(y))./diff(n); k=1; for i=1:length(n)-2 if(x(i)>0&x(i+1)=max(abs(y))/2) a(k)=n(i+1);k=k+1; end end if(k==1) a=[]; end; if(nargout> y.*W; >> y=ans(1:64) y= Columns through 14 -26.1457 22.0108 -16.6929 11.0505 -5.9469 2.1383 -0.1752 -2.5677 6.5392 -11.6385 17.0760 -21.9823 25.5232 0.3312 Columns 15 through 28 -27.0092 25.9882 -22.3081 16.1420 -7.9718 -1.4667 11.2715 -20.4830 28.2001 -33.6896 36.4741 -36.3885 33.5970 -28.5695 Columns 29 through 42 22.0192 -14.8106 7.8491 -1.9662 -2.1855 4.2128 -4.0296 1.7736 -6.1625 10.4659 -13.8443 15.5674 -15.1135 1.8643 Columns 43 through 56 12.2413 -7.0268 -0.1404 8.6015 -17.5069 25.9199 -32.9315 37.7732 -39.9115 39.1150 -35.4821 29.4292 -21.6382 12.9721 Columns 57 through 64 -4.3673 -3.2817 9.2320 -12.9823 14.3315 -13.3987 10.6022 -6.6002 >> Y=fft(y); >> plot(0:63,abs(Y)); >> a=peak_finding(abs(Y),0:63) Trang 88 a= 28 30 34 36 %%%%%%%%%%%%% D.Kiểm tra với hàm cửa sổ Hamming clear N=64; n=0:63; W=0.54+0.46*cos(2*pi*n/(N-1)); y=20*exp(j*(2*n+3))+20*exp(j*(2.27*n+3)); y1=y.*W; Y1=fft(y1); plot(n,abs(Y1)) Trang 89 >> title('cua so Hamming'); >> xlabel('n'); >> ylabel('A'); >> a=peak_finding(abs(Y1),n); >> a a= 20 23 EXERCISE 3.3:Measure Resolution A Hàm peak_finding ta vừa viết trả số lượng peak tín hiệu.Ta kiểm tra nó: %%%%%%%%%%% Trang 90 clear N=64; n=0:63; W=0.54+0.46*cos(2*pi*n/(N-1)); y=20*exp(j*(2*n+3))+20*exp(j*(2.27*n+3)); y1=y.*W; Y1=fft(y1); plot(n,abs(Y1)) >> title('cua so Hamming'); >> xlabel('n'); >> ylabel('A'); >> [a,l]=peak_finding(abs(Y1),n); >> a a= 20 23 >>l l= %%%%%%%% B.Viết script khởi tạo tín hiệu tính toán Chương trình viết MATLAB sau: %%%%%%%%%%%%% clear A1=10; A2=10; Trang 91 n=0:63; L=64; q1=3.8; q2=q1; delta=0; while delta> resolution Nhap delta=0.19 delta=0.19 Score=100 phantram Nhap delta=0.17 delta=0.17 Score=80 phantram Nhap delta=0.16 delta=0.16 Score=70 phantram Nhap delta=0.13 delta=0.13 Score=50 phantram Nhap delta=0.12 delta=0.12 Score=50 phantram Nhap delta=0.1 delta=0.1 Score=30 phantram Nhap delta=0.09 Trang 92 delta=0.09 Score=10 phantram Nhap delta=0.08 delta=0.08 Score=10 phantram Nhap delta=0.06 delta=0.06 Score=0 phantram Nhap delta=0.05 delta=0.05 Score=0 phantram Nhap delta=0.04 delta=0.04 Score=0 phantram Nhap delta=0.03 delta=0.03 Score=0 phantram Nhap delta=0.2 delta=0.2 Score=100 phantram >> %%%%%%%%%%%% C Nhận thấy ΔW tiến gần đến 4π /L=0.19 score =100% Khi ΔW=32 k=1;clear m;clear p;clear n; L=input('Nhap L=');n=0:L-1; if L1 plot(m,p); title('do thi score theo delta '); >> xlabel('delta'); Trang 94 >> ylabel('score'); end end Chạy hàm Window Command ta kết sau: %%%%%%% resolution1('chunhat') Nhap L=64 Nhap delta=0.19 delta=0.19 Score=100 phantram Nhap delta=0.18 delta=0.18 Score=90 phantram Nhap delta=0.17 delta=0.17 Score=90 phantram Nhap delta=0.16 delta=0.16 Score=40 phantram Nhap delta=0.15 delta=0.15 Score=40 phantram Nhap delta=0.14 delta=0.14 Score=30 phantram Nhap delta=0.12 delta=0.12 Score=30 phantram Nhap delta=0.11 delta=0.11 Score=30 phantram Nhap delta=0.1 delta=0.1 Score=30 phantram Nhap delta=0.09 delta=0.09 Score=10 phantram Nhap delta=0.08 delta=0.08 Score=30 phantram Nhap delta=0.07 delta=0.07 Score=0 phantram Nhap delta=0.06 delta=0.06 Score=0 phantram Trang 95 %% Trường hợp L=128; %%%% clear >> resolution1('chunhat') Nhap L=128 Nhap delta=4*pi/128 delta=0.0981748 Score=100 phantram Nhap delta=0.09 delta=0.09 Score=100 phantram Nhap delta=0.08 delta=0.08 Score=70 phantram Nhap delta=0.075 delta=0.075 Score=70 phantram Nhap delta=0.07 delta=0.07 Score=30 phantram Nhap delta=0.065 delta=0.065 Score=50 phantram Nhap delta=0.06 delta=0.06 Score=30 phantram Trang 96 Nhap delta=0.055 delta=0.055 Score=30 phantram Nhap delta=0.05 delta=0.05 Score=40 phantram Nhap delta=0.045 delta=0.045 Score=30 phantram Nhap delta=0.04 delta=0.04 Score=0 phantram Nhap delta=0.035 delta=0.035 Score=0 phantram D.kiểm tra với hàm cửa sổ hamming,hanning %%Cửa sổ hamming clear >> resolution1('hamming') Nhap L=64 Nhap delta=0.19 delta=0.19 Score=100 phantram Nhap delta=0.18 delta=0.18 Score=90 phantram Trang 97 Nhap delta=0.17 delta=0.17 Score=90 phantram Nhap delta=0.16 delta=0.16 Score=80 phantram Nhap delta=0.15 delta=0.15 Score=80 phantram Nhap delta=0.14 delta=0.14 Score=30 phantram Nhap delta=0.13 delta=0.13 Score=40 phantram Nhap delta=0.12 delta=0.12 Score=30 phantram Nhap delta=0.11 delta=0.11 Score=20 phantram Nhap delta=0.1 delta=0.1 Score=40 phantram Nhap delta=0.09 delta=0.09 Score=0 phantram Nhap delta=0.08 delta=0.08 Score=0 phantram Nhap delta=1 Trang 98 %%Cửa sổ hanning %%%%%%% clear >> resolution1('hanning') Nhap L=64 Nhap delta=0.19 delta=0.19 Score=90 phantram Nhap delta=0.18 delta=0.18 Score=80 phantram Nhap delta=0.17 delta=0.17 Score=100 phantram Nhap delta=0.16 delta=0.16 Score=100 phantram Nhap delta=0.15 delta=0.15 Score=80 phantram Nhap delta=0.14 delta=0.14 Score=20 phantram Nhap delta=0.13 delta=0.13 Score=20 phantram Nhap delta=0.12 delta=0.12 Score=20 phantram Nhap delta=0.11 delta=0.11 Score=30 phantram Nhap delta=0.1 delta=0.1 Score=20 phantram Nhap delta=0.09 delta=0.09 Score=10 phantram Nhap delta=0.08 delta=0.08 Score=0 phantram Nhap delta=0.07 delta=0.07 Score=0 phantram Trang 99 ++++++++ The End ++++++++++ Trang 100

Ngày đăng: 10/08/2016, 11:09

Từ khóa liên quan

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

Tài liệu liên quan