我有一些数据有 DC 偏移并且可能有轻微的斜率。信号是两个主峰(类似于高斯),随后是衰减振荡。
我尝试了以下代码,但这不会删除 DC 偏移 - 它会删除弯曲的偏移(窦?)。
function [ filteredData ] = fourierFilter( inputData )
factor = 8;
N = 1024*factor;
dataRaw = zeros([1 N]);
dataStart = N/2 - round(size(inputData,2)/2);
indices = dataStart:(dataStart+size(inputData,2))-1;
dataRaw(indices) = inputData;
% transform to fourierspace
fourierSpectrum = (fftshift(fft(dataRaw)));
% add filter
delta = 1*factor/4;
indicesfftfilter = N/2-delta:N/2+delta;
fourierSpectrum(indicesfftfilter) = 0;
% back transform
filteredData = real(ifft(ifftshift(fourierSpectrum)));
filteredData = (filteredData(indices));
这是数据(蓝色)和过滤曲线(红色)的示例delta = 3*factor/4