Adaptive filter output shows a offset in frequency domain?
2 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I am trying to use Matlab's adaptive filter object to remove the background noise from my EMI measurment based on the follwoing structure and the specfic one i am using is: dsp.FrequencyDomainAdaptiveFilter.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1447797/image.png)
Here is the comparison of x(k) only background noise and d(k) abs EMI + background noise in ffrequency domain: green is d(k) and yellow is x(k); exact same input data used in the follwing reusults.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1447802/image.png)
The input singal x(k) is the fed by measured background Nosie (when everything else is off); and the Desired signal d(k) is fed by sum of absolute EMI + background Nosie, ideally i am expecting the output signal y(k) should match the x(k) in the FFT plot, however, i found there is a amplitude offset exist (green trace is x(k) and yellow trace is y(k)). Does anyone know how could get rid of this offset and why?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1447807/image.png)
Since my target is the Error Signal which equals to absolute EMI noise (after d(k)-y(k)); if the amplitude offset in frequency has not been taken care of; what i found is that the e(k) in frequency domain plot is almost identical to the input x(k) which means the background noise hasn't been removed, right? below is the comaprison between d(k) and e(k) in frequency domain: green is d(k): abs EMI + background noise and yellow is e(k): abs EMI only ideally.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1447812/image.png)
I am wondering is this caused by i haven't compesnated the previous frequency domian offset between x(k) and y(k) correct?
if so, i tried compensate the offset directly in frequency domain but doesn't seems to be right becuase the differnence is larger than what i expected. i alos tried to remove the offset from time domain and the results is simialr to figure 5 which also doens't seem to be right.
How should i fix it? thanks a lot for any help.
0 个评论
回答(1 个)
Mrutyunjaya Hiremath
2023-8-2
Try this ..
% Load and preprocess your EMI measurement data
% Assuming you have x(k) as background noise and d(k) as the signal with noise
% Perform any necessary preprocessing, such as normalization or DC removal
% Set up the adaptive filter
filterLength = 64; % Adjust the filter length based on your requirements
stepSize = 0.01; % Adjust the step size based on your requirements
adf = dsp.FrequencyDomainAdaptiveFilter('Length', filterLength, 'StepSize', stepSize);
% Initialize variables to store the output signal and error signal
outputSignal = zeros(size(x)); % Assuming x(k) is the background noise signal
errorSignal = zeros(size(d)); % Assuming d(k) is the signal with noise
% Process the signals in blocks or frames, if needed
blockSize = 1024; % Adjust the block size based on your data size and memory constraints
numBlocks = ceil(length(d) / blockSize);
for i = 1:numBlocks
% Extract the current block of signals
startIdx = (i - 1) * blockSize + 1;
endIdx = min(i * blockSize, length(d));
xBlock = x(startIdx:endIdx);
dBlock = d(startIdx:endIdx);
% Apply the adaptive filter to remove the background noise
[yBlock, errBlock] = adf(xBlock, dBlock);
% Store the output and error signals for the entire data
outputSignal(startIdx:endIdx) = yBlock;
errorSignal(startIdx:endIdx) = errBlock;
end
% Visualize the results in the frequency domain
Fs = 1000; % Adjust the sampling frequency based on your data
f = Fs * (0:(length(d)-1)) / length(d); % Frequency axis
figure;
subplot(2, 1, 1);
plot(f, abs(fft(x))); % Plot the FFT of x(k)
hold on;
plot(f, abs(fft(outputSignal))); % Plot the FFT of the filtered signal y(k)
xlabel('Frequency (Hz)');
ylabel('Magnitude');
legend('FFT of x(k)', 'FFT of y(k)');
title('Comparison of FFT of Input and Filtered Signal');
subplot(2, 1, 2);
plot(f, abs(fft(d))); % Plot the FFT of d(k) with EMI noise
hold on;
plot(f, abs(fft(errorSignal))); % Plot the FFT of the error signal (abs EMI noise)
xlabel('Frequency (Hz)');
ylabel('Magnitude');
legend('FFT of d(k)', 'FFT of e(k)');
title('Comparison of FFT of Original Signal and Error Signal');
% Analyze the results and adjust the filter parameters if needed
Please note that the code above assumes a basic block-based processing approach. You may need to adjust the parameters and other aspects of the code based on your specific data and requirements.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Adaptive Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!