通訊實驗matched filter結報
撰寫時間 : 2022/05/13
實驗目的
- 接收端利用匹配濾波器,配合適當取樣時間來解調傳送端傳送的的兩波形所代表的二位元信號。
- 如何模擬實現匹配濾波器。
matched filter 實驗原理
- 首先binary sequence ,會進行訊號調變(modulation),這裡使用pulse amplitude modulation(PAM),首先每個bit通過symbol mapper,將每個bit映射到一個數值,分為以下兩種
- 接下來通過一個pulse shaping filter ,一般使用方波,調變後的訊號就是,就是代表這個波型的振幅。
- 通過一個channel,一般假設是AWGN channel,因此接收端接收到的訊號就是。
- 接收端通過一個filter,為了得到極大化SNR值,這個filter會根據輸入訊號的波型,設計一個match 的波型,設計準則為將輸入訊號先做反轉再做延遲。
- 取樣一段時間後才會輸出訊號,當取樣時間,此時matched filter等於correlator,而若又是方波,matched filter等效上積分器,而從電子學可知積分器可以過濾高頻雜訊。
- 最後是一個判斷機制,判斷這個數值是0和1,需要設計一個threshold ,極小化位元錯誤率。
- 最大化(當取樣時間)的SNR,使對抗雜訊的能力增加
首先先正規化received filter的限制為。
要求出noise的power就是取其變異數(二階動差 - 一階動差平方),代表是AC的power(總功率的power - DC的power)。
因此SNR可以改寫為
由於底下該項是常數,因此使用柯西不等式,可以求出SNR所能到達最大值為
等號成立的條件為兩向量平行,即為或是,物理意義就是將輸入訊號先做反轉再做延遲,此received filter設計就是matched filter。
lab1
問題 : duration設定為4 symbol periods, 畫出在與的transmitted waveform和received waveform並比較差異。
|
|
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
|
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
|
定義信噪比 ,其中代表高斯雜訊的一個定值()、代表on-off keying每個bit的平均能量,因此降低SNR,保持一致,等同降低降低每個bit傳送時的平均能量,由於,因此BER會變差。
而範例程式這邊與我上述直覺理解不同點是在維持下,調動noise的power ,降低SNR,會讓變大,因此接收端(RX)訊號右圖會比左圖變化幅度還大。
lab2-1
問題 : 解釋程式Data_bit = (rand(1, data_number) > 0.5 )
為何可產生random bits?bit 0 和bit 1,其發生機率理論上應為何?實際於模擬是否符合理論預測?
指令rand(M,N)
代表返回一個的矩陣,每個element的值是取區間0到1的均勻分布$ U \sim (0, 1)$並使用logic判斷式判斷是否大於0.5,若符合回傳1,反之回傳0,回傳的data type是logic
。
由於是均勻分布,0到0.5的區間機率是,判定為logic 0;0.5到1的區間機率是,判定為logic 1,實際模擬如下圖
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
藉由做很多次的隨機試驗,可以得到relative frequency ,當試驗次數越多,會趨於機率,記為,由上圖可知data number越多,機率會趨於。
lab2-2
問題 :
其中Data_pulse = reshape(Data_pulse_array, 1, length(p1)*data_number)
代表意義。
Data_bit
為由機率各半()的logic 0和1形成的矩陣,Data_pulse_array
為將Data_bit
的值拷貝成的矩陣,此時data type是double
,最後reshape
將的矩陣,以column為順序,轉換為(1,length(p1)*data_number)
的矩陣,代表意義是每10個單位傳送一個symbol。
lab3
問題 : 沒有雜訊下,matched filter output 理論值與模擬值為何?
首先計算兩方波做convolution,如下圖所示
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
兩個方波做convolution等於一個三角波,數學式記為
由於本題假設沒有雜訊,因此傳送端訊號等於接收端訊號,接下來與matched filter做convolution計算為根據上述知識,使用,可計算結果,使用matlab模擬驗證,假設傳送bit為1101
,matched filter output 如下
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
取中時刻的時間,即上圖中simple index在10、20、30、40下的值,由於大小是,因此需要除以一個scaling 轉為原本波型的大小,本題就是,最後繪製如下圖,藍點代表是時間在10、20、30、40下的數值除以一個10的scaling。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
lab4
問題 : 解釋D_demapping=D_filtered(10:10:end)/10
。
同lab3問題,取matched filter在下的輸出,並除上一個的scaling。
lab5
問題 : 解釋sgma = sqrt( 0.5/EbN0/2*10 )
。
如lab1觀念,定義信噪比 ,其中代表高斯雜訊的一個定值()、代表on-off keying每個bit的平均能量,由於本題條件,因此,另外假設取樣頻率,每個sample point的noise power為,計算值如下
SNR可改寫為
lab6
問題 : 畫出OOK中BER對SNR理論值與實際值做圖。
在機率equally likely 條件下,OOK的bit error rate(BER)理論值計算為
與實際用matlab模擬值
繪圖如下
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
由上圖可知理論值計算與matlab模擬值之間誤差非常小。
lab7
問題 : 在與的情況下,畫出matched filter output 的conditional pdf 與的理論值與模擬值。
如果一開始傳送訊號是0
,提取輸出訊號並存入另一個自定義的array,代表選取指定事前機率下的輸出數據。
下指令histogram(X,'Normalization','pdf')
畫各個數值區間內的統計數量,後面那2個參數是取數據X
的probability density function。
理論值計算下指令normpdf
,代表使用常態(高斯)分布,其中mean 是0,而standard deviation(標準差) 是需要乘以的scaling,原因是根據lab3觀念,經過convolution後的訊號要除以的scaling才是最終的,其中也包括雜訊,因此。
分別就不同SNR下畫出conditional pdf與的理論值與模擬值。
|
|
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
|
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
|
降低SNR,在維持的條件下,調動noise的power ,會讓變大,因此右圖的PDF會比左圖的PDF還矮胖。
程式
% matched filter
% ‐ on‐off keying (OOK) using rectangular pulse (T=1)
% That is, when OFF, assuming A=0, thus E1 = 0
% when ON: assuming A=1, thus E2 = 1
% The "average bit energy" (Eb) = (E1+E2)/2 = 1/2
%
clear,clc,close all;
%% parameters
data_number = 10^5; % # of bits
EbN0dB_vec = [0:2:10 11.5]; % Eb/N0 in dB
Fs = 10; % sampling frequency (used to generate received samples)
%% transmitter
Data_bit = (rand(1,data_number) > 0.5 ); % random bits
p1 = ones(1,Fs); % discrete‐time rectangular pulse that represents one symbol
Data_pulse_array = (p1')*Data_bit;
Data_pulse = reshape(Data_pulse_array,1,length(p1)*data_number);
%% AWGN channel and receiver
% AWGN channel
[a, b] = size(Data_pulse);
% EbN0dB = 3;
EbN0dB = 10;
EbN0 = 10^(EbN0dB/10); % EbN0 is now in linear scale
sgma = sqrt(0.5/EbN0/2*10);
noise = normrnd(0, sgma, a, b);
Data_receive = Data_pulse + noise; % received samples
% receiver
D_filtered = conv(Data_receive,p1); % MF output
D_demapping = D_filtered(10:10:end) / 10; % sampling at symbol rate
% decsion based on D_demapping
D_demap_N = (D_demapping > 0.5); % >0.5: 1; <=0.5: 0
%% split two parts
index_0 = 1;
for i = 1:data_number
if Data_bit(i) == 0 % TX == 0
D_demapping_0(index_0) = D_demapping(i);
index_0 = index_0 + 1;
end
end
index_1 = 1;
for i = 1:data_number
if Data_bit(i) == 1
D_demapping_1(index_1) = D_demapping(i);
index_1 = index_1 + 1;
end
end
%% generate plots
figure;
hold on;
xaxis = -2.5:0.01:2.5;
histogram(D_demapping_0, 'FaceColor', '#0072BD','Normalization','pdf');
histogram(D_demapping_1, 'FaceColor', '#D95319','Normalization','pdf');
plot(xaxis,normpdf(xaxis,0,sgma / sqrt(10)), 'LineWidth',3); %need to scaling 10 with line 30
plot(xaxis,normpdf(xaxis,1,sgma / sqrt(10)),'r', 'LineWidth',3); %need to scaling 10 with line 30
xlabel('y(T)');
ylabel('probability density');
legend('bit 0 (simulation)', 'bit 1 (simulation)', 'bit 0 (theory)','bit 1 (theory)','FontSize',13);
grid on;
title('conditional PDF of (y(T) | bit 0 sent) and f(y(T) | bit 1 sent)','FontSize',15);