在不影響計算結果精度的前提下,為了降低計算成本,通常對信號進行減采樣。
減采樣之后的樣本仍需滿足大於奈奎斯特頻率,以避免產生混疊。
為了避免發生混疊,通常應在減采樣前施加一個抗混疊低通濾波器。
https://cnx.org/contents/p8E-T146@5/Decimation-and-Downsampling
https://dspguru.com/dsp/faqs/multirate/decimation/
比如一個128Hz的信號,想減采樣至32Hz,系數M=4。我們可以先對原始信號進行抗混疊低通濾波,2M=8,截止頻率為128/8 = 16Hz。然后進行downsample。減采樣之后的樣本仍滿足大於奈奎斯特頻率,避免產生混疊。
decimate
減采樣之前,為了防止產生混疊對輸入進行低通濾波(By default, decimate uses a lowpass Chebyshev Type I IIR filter of order 8.)
y = decimate(x,r)
減采樣系數為r,length(y) = ceil(length(x)/r)
y = decimate(x,r,n)
uses a Chebyshev filter of order n. Orders above 13 are not recommended because of numerical instability.
指定濾波器階次,由於數值不穩定,一般階次不超過13。
y = decimate(x,r,'fir')
uses an FIR filter designed using the window method with a Hamming window. The filter has order 30.
使用基於窗方法設計的FIR濾波器,默認階次為30。
y = decimate(x,r,n,'fir')
使用基於窗方法設計的FIR濾波器,並指定濾波器階次。
For better results when r is greater than 13, divide r into smaller factors and call decimate several times.
為了獲得更好的結果,當r大於13時,將r分成較小的因子,並多次抽取。
r = 13; n = 16:365; lx = length(n); x = sin(2*pi*n/153) + cos(2*pi*n/127); plot(0:lx-1,x,'o') hold on y = decimate(x,r,82,'fir'); stem(0:r:lx-1,y,'ro','filled','markersize',4) legend('Original','Decimated','Location','south') xlabel('Sample number') ylabel('Signal')
downsample
y = downsample(x,n)
decreases the sampling rate of x by keeping every nth sample starting with the first sample. x can be a vector or a matrix. If x is a matrix, each column is considered a separate sequence.
對x減采樣,從第一個樣本開始,每n個樣本取一個。如果x是矩陣,每一列被看做是一個獨立序列。
y = downsample(x,n,phase)
指定相位偏移
x = [1 2 3 4 5 6 7 8 9 10]; y = downsample(x,3) y = 1 4 7 10 y = downsample(x,3,2) y = 3 6 9
resample
Resample uniform or nonuniform data to new fixed rate
將均勻或非均勻數據重新采樣為新的固定采樣頻率
y = resample(x,p,q)
resamples the input sequence, x, at p/q times the original sample rate. If x is a matrix, then resample treats each column of x as an independent channel. resample applies an antialiasing FIR lowpass filter to x and compensates for the delay introduced by the filter.
對x重采樣,采樣頻率是原始采樣頻率的p/q 倍。如果x是矩陣,每一列被看做是一個獨立序列。重采樣將抗混疊FIR低通濾波器應用於x並補償濾波器引入的延遲。
y = resample(x,p,q,n)
uses an antialiasing filter of order 2 × n × max(p,q).
y = resample(x,p,q,n,beta)
specifies the shape parameter of the Kaiser window used to design the lowpass filter.
y = resample(x,p,q,b)
filters x using the filter coefficients specified in b. b為濾波器系數向量。