上次我们讲到如果混叠没能成功避免,那么混叠后的信号就会偷偷混入重建后的信号。那么这个经过伪装的“伪装信号”的频率是多少呢?他会出现在频谱中的哪里呢?这是可以通过精确计算得到的。
先从奥本海姆的信号与系统中的一幅插图说起,奥本海姆老师想要通过这幅图说明混叠,所绘制的波形为下图公式所示的余弦函数。
图中的ωo表示原始信号的频率,ωs表示采样频率。这幅图一共有四张,前两张的采样频率分别是原始频率的6倍和3倍,所以重建后的信号并没有出现混叠如下图所示。
点击图像放大
由于我很喜欢这个例子,所以我就用matlab把它仿真了一下。此处我的余弦函数的采样频率为60Hz, 所以第一个连续信号(下图中第一行)的原始频率为10Hz, 此时采样频率为原始信号频率的6倍。第二个连续信号(下图中第三行)的原始频率为20Hz, 此时采样频率为原始信号频率的3倍。(箭头没能仿真成功,嘻嘻)
点击图像放大
Matlab代码如下:
%:by J27 copyright! %% 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 = 60 - 40 = 20Hz
For (d) ωo = 50Hz ; Fa = ωs - ωo = 60 - 50 = 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代码:
%:by J27 copyright! %% 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节 天国近了,你们应当悔改!
*配图与本文无关*