Adaptive filter output shows a offset in frequency domain?

4 views (last 30 days)
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.
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.
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?
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.
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.

Answers (1)

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath on 2 Aug 2023
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.
  1 Comment
Tonglei
Tonglei on 2 Aug 2023
Firstly, thanks for your reply.
However, based on the your method, i still got something similar to my previous script, as howing below:
the offset in frequncy domain is still there.
by comparing the mt script and your method, i think the main difference is that i haven't break the input data x(k) and d(k) into blocks manually; instead, i am using the fdaf('BlockLength',10) since i think Matlab is doing the block division automatically.
I have attahce my original script and new script (based on your method), could you have a look to see if i have misunderstood your method?
Thank you so much.

Sign in to comment.

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!