信號的採樣和奇妙的混疊(Aliasing) 貳

混疊頻率的計算

     上次我們講到如果混疊沒能成功避免,那麼混疊後的信號就會偷偷混入重建後的信號。那麼這個經過僞裝的“僞裝信號”的頻率是多少呢?他會出現在頻譜中的哪裏呢?這是可以通過精確計算得到的。

     先從奧本海姆的信號與系統中的一幅插圖說起,奧本海姆老師想要通過這幅圖說明混疊,所繪製的波形爲下圖公式所示的餘弦函數。

     圖中的ωo表示原始信號的頻率,ωs表示採樣頻率。這幅圖一共有四張,前兩張的採樣頻率分別是原始頻率的6倍和3倍,所以重建後的信號並沒有出現混疊如下圖所示。


點擊圖像放大

由於我很喜歡這個例子,所以我就用matlab把它仿真了一下。此處我的餘弦函數的採樣頻率爲60Hz, 所以第一個連續信號(下圖中第一行)的原始頻率爲10Hz, 此時採樣頻率爲原始信號頻率的6倍。第二個連續信號(下圖中第三行)的原始頻率爲20Hz, 此時採樣頻率爲原始信號頻率的3倍。(箭頭沒能仿真成功,嘻嘻)


點擊圖像放大

Matlab代碼如下:

%% sampling freqency 6 times continous signal  
Fs = 60;                        % Sampling Freq. 
Fo = Fs/6;                      % freq. of continous Signal  
T = 1/Fs;                       % sampling period
tmin = -pi/15.7;                % lower limit of time vector
tmax = pi/15.7;                 % upper limit of time vector
Bins = 400;                     % Number of Bins
t = linspace(tmin, tmax, Bins); % time space vector
nmin = ceil(tmin / T);          % lower limit of num vector
nmax = floor(tmax / T);         % upper limit of num vector
n = nmin:nmax;                  % discrete space vector

CosineSignal = cos(2.*pi.*Fo.*t);
SampleSignal = cos(2.*pi.*Fo.*n.*T);

subplot(4,1,1)
plot(t,CosineSignal,'k','LineWidth',2);
title('\fontsize{35}Sampling freqency 6 times continous signal. i.e. Proper sampling');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off

subplot(4,1,2)
plot(t,CosineSignal,'--k','LineWidth',2);
title('\fontsize{35}Rebuild continous signal with sampled discrete signal');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off

%% sampling freqency 3 times continous signal  
Fs = 60;                        % Sampling Freq. 
Fo = Fs/3;                      % freq. of continous Signal  
T = 1/Fs;                       % sampling period
tmin = -pi/15.7;                % lower limit of time vector
tmax = pi/15.7;                 % upper limit of time vector
Bins = 400;                     % Number of Bins
t = linspace(tmin, tmax, Bins); % time space vector
nmin = ceil(tmin / T);          % lower limit of num vector
nmax = floor(tmax / T);         % upper limit of num vector
n = nmin:nmax;                  % discrete space vector

CosineSignal = cos(2.*pi.*Fo.*t);
SampleSignal = cos(2.*pi.*Fo.*n.*T);

subplot(4,1,3)
plot(t,CosineSignal,'k','LineWidth',2);
title('\fontsize{35}Sampling freqency 3 times continous signal. i.e. Proper sampling');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off

subplot(4,1,4)
plot(t,CosineSignal,'--k','LineWidth',2);
title('\fontsize{35}Rebuild continous signal with sampled discrete signal');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off    

     在用matlab仿真時,重建信號(即圖像中灰色虛線)的頻率由於沒有出現混疊。則在用matlab繪製圖像時,重建的COS波形的頻率沿用了原始信號的頻率Fo。但在仿真下面圖像時就必須要精確的計算出混疊後的頻率Fs才能繪製出混疊信號的波形。



點擊圖像放大

     要想畫出上圖中的虛線,即僞裝後變慢了的信號,必須要精確的知道信號變慢了多少。對於欠採樣不太嚴重的情況(即,原始頻率小於採樣頻率但大於採樣頻率的一半。Fs/2<Fo<Fs),如上圖中的情況。則可以使用如下計算公式中的情形(c)和情形(d):


在本例中我所使用的採樣頻率爲60Hz, 按照公式(c)和公式(d)則發生混疊後的混疊頻率分別爲:

For   (c)    ωo = 40Hz ;     Fa = ωs - ωo = 20Hz

For   (d)    ωo = 50Hz ;     Fa = ωs - ωo = 10Hz


     如果原始信號的頻率遠遠高於採樣頻率,即原始頻率Fo不僅大於Fs還有可能大於Fs的2,3,4,5...倍則可以使用如下公式。fa表示混疊頻率,fs表示採樣頻率,f表示原始信號的最高頻。式中||表示求絕對值,式中(closest integermultiple of fs)表示整數倍於最接近原始頻率f的倍數。例如,如果採樣頻率爲100Hz,原始信號的最高頻爲710Hz則這是式中的(closest integermultiple of fs)等於7,即7*fs。


   現假設信號採樣頻率爲100 Hz,輸入信號包含下列頻率:25 Hz、70 Hz、160 Hz和510 Hz。 低於50 Hz奈奎斯特頻率纔可正確採樣,超過50 Hz的頻率顯示爲混疊,所以只有頻率爲25Hz的信號才能被正確採樣。fs/2爲奈奎斯特頻率即採樣頻率的一半。


其中,頻率超過50Hz的信號的混疊頻率計算公式爲:

(1) 當輸入信號的頻率F2爲70Hz時,採樣頻率Fs爲100Hz。按照奈奎斯特採樣定律,要想對70Hz的輸入信號充分採樣,採樣頻率至少要大於140Hz,即輸入信號頻率的兩倍。所以發生了混疊,由於輸入頻率爲70,所以離採樣頻率100最近的整數倍數是1(即,這裏的(closest integermultiple of fs) = 1  計算結果如下:     

                                                                                         F2 Alias = |100 - 70| = 30Hz


(2) 當輸入信號的頻率F3爲160Hz時,採樣頻率爲Fs100Hz。採樣頻率低於輸入信號的頻率,發生了混疊,由於輸入頻率爲160,所以離採樣頻率100最近的整數倍數是2(即,這裏的(closest integermultiple of fs) = 2  計算結果如下:     

F3 Alias = |2*100 - 160| = 40Hz


(3) 當輸入信號的頻率F4爲510Hz時,採樣頻率爲Fs100Hz。採樣頻率低於輸入信號的頻率,發生了混疊,由於輸入頻率爲510,所以離採樣頻率100最近的整數倍數是5(即,這裏的(closest integermultiple of fs) = 5  計算結果如下:     

F4 Alias = |5*100 - 510| = 10Hz


混疊頻率即摺疊頻率:     

     混疊頻率有時又叫摺疊頻率,只需把超過奈奎斯特頻率(Fs/2)的頻段或是超過採樣頻率(Fs)的頻段以奈奎斯特頻率或採樣頻率爲中軸對摺過去就好了。或者說是以奈奎斯特頻率或採樣頻率爲中軸的鏡像。如下圖,一個6Hz的信號以奈奎斯特頻率3.5Hz爲中軸摺疊爲1Hz的信號。同理,一個8Hz的信號以採樣頻率7Hz爲中軸摺疊爲頻率爲6Hz的信號。



     好了, 計算公式以及詳細的計算方法都已經給出來了。最後用Matlab把教科書中的帶有混疊的那部分圖示仿真出來(注意:重建後的混疊信號我用藍色的虛線表示出來了)。


點擊圖像放大

Matlab代碼:

%% sampling freqency 3/2 times continous signal  
Fs = 60;                        % Sampling Freq. 
Fo = 4*Fs/6;                    % freq. of continous Signal  
T = 1/Fs;                       % sampling period
tmin = -pi/15.7;                % lower limit of time vector
tmax = pi/15.7;                 % upper limit of time vector
Bins = 400;                     % Number of Bins
t = linspace(tmin, tmax, Bins); % time space vector
nmin = ceil(tmin / T);          % lower limit of num vector
nmax = floor(tmax / T);         % upper limit of num vector
n = nmin:nmax;                  % discrete space vector

CosineSignal = cos(2.*pi.*Fo.*t);
SampleSignal = cos(2.*pi.*Fo.*n.*T);

figure;
subplot(4,1,1)
plot(t,CosineSignal,'k','LineWidth',2);
title('\fontsize{35}Sampling freqency 1.5 times continous signal. Improper sampling resualt in Aliasing');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off

%figure out Aliasing freq.
Fa = abs(Fo-Fs);
CosineSignal = cos(2.*pi.*Fa.*t);

subplot(4,1,2)
plot(t,CosineSignal,'--b','LineWidth',2);
title('\fontsize{35}Rebuild continous signal with sampled discrete signal');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off

%% sampling freqency 6/5 times continous signal  
Fs = 60;                        % Sampling Freq. 
Fo = 5*Fs/6;                    % freq. of continous Signal  
T = 1/Fs;                       % sampling period
tmin = -pi/15.7;                % lower limit of time vector
tmax = pi/15.7;                 % upper limit of time vector
Bins = 400;                     % Number of Bins
t = linspace(tmin, tmax, Bins); % time space vector
nmin = ceil(tmin / T);          % lower limit of num vector
nmax = floor(tmax / T);         % upper limit of num vector
n = nmin:nmax;                  % discrete space vector

CosineSignal = cos(2.*pi.*Fo.*t);
SampleSignal = cos(2.*pi.*Fo.*n.*T);

subplot(4,1,3)
plot(t,CosineSignal,'k','LineWidth',2);
title('\fontsize{35}Sampling freqency 1.2 times continous signal. Improper sampling resualt in Aliasing');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off

% figure out Aliasing freq.
Fa = abs(Fo-Fs);
CosineSignal = cos(2.*pi.*Fa.*t);

subplot(4,1,4)
plot(t,CosineSignal,'--b','LineWidth',2);
title('\fontsize{35}Rebuild continous signal with sampled discrete signal');
hold on
stem(n*T,SampleSignal,'r','filled','LineWidth',2)
hold off


(全文完)


鳴謝:

【1】http://www.ni.com/white-paper/2709/zhs/  美國國家儀器(NI) 技術白皮書

【2】signals and systems 第二版 奧本海姆

【3】Matlab 2017a

【4】http://e2e.ti.com/blogs_/archives/b/precisionhub/archive/2015/09/04/aliasing-in-adcs-not-all-signals-are-what-they-appear-to-be  德州儀器


謝謝收看!

再見!


《聖經》馬太福音3章2節  天國近了,你們應當悔改!


*配圖與本文無關*





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章