How to filter multiples non harmonic frequencies?
2 views (last 30 days)
Show older comments
Hello,
I'm trying to filter the effects of background noise (Tamb.mat) from a signal (Tech.mat). In order to do that I analyse the spectrum of the signals in order to find the frequencies of the background noise that have an impact on the main signal. The next step concerns the design of a filter that is capable of eliminate the background noise frequencies affecting the main signal. However, the noise frequencies affecting the signal span over a large bandwidth and seems to be non-harmonic. Is there a filter design that can solve this problem?
Thanks in advance for your help.
Ts=100;
Fs=1/Ts;
LTemp=length(Tech);
f = Fs*(0:(LTemp/2))/LTemp;
fftTech=fft(Tech);
P2Tech = abs(fftTech/LTemp);
P1Tech = P2Tech(1:LTemp/2+1);
P1Tech(2:end-1) = 2*P1Tech(2:end-1);
fftTamb=fft(Tamb);
P2Tamb = abs(fftTamb/LTemp);
P1Tamb = P2Tamb(1:LTemp/2+1);
P1Tamb(2:end-1) = 2*P1Tamb(2:end-1);
[pkAmb,locsAmb]=findpeaks(P1Tamb);
[pkEch,locsEch]=findpeaks(P1Tech);
fpkAmb=f(locsAmb);
fpkEch=f(locsEch);
Df=f(2)-f(1);
[fpks_comp]=ismembertol(fpkAmb,fpkEch,Df, 'DataScale', 1);
idxfpks_comp=find(fpks_comp>0);
fcomoun=fpkAmb(idxfpks_comp);
logicfcomoun=ismember(f,fcomoun);
idxlogicfcomoun=find(logicfcomoun>0);
fpkscomoun=f(idxlogicfcomoun);
figure;
subplot(221)
plot(t_IR,Tamb,'r','LineWidth',linewidth)
xlim([0 max(t_IR)])
xlabel('time (s)','FontSize', fontsize)
ylabel('Temperature (°C)','FontSize', fontsize)
title('Temperature ambiante')
xt = get(gca, 'XTick');
set(gca, 'FontSize', fontsize)
subplot(222)
semilogy(f,P1Tamb,'r','LineWidth',linewidth)
hold on
semilogy(f(idxlogicfcomoun),P1Tamb(idxlogicfcomoun),'ok','LineWidth',linewidth)
xlim([0 max(f)])
xlabel('Frequence (Hz)','FontSize', fontsize)
ylabel('Temperature (°C)','FontSize', fontsize)
title('FFT Temperature ambiante')
xt = get(gca, 'XTick');
set(gca, 'FontSize', fontsize)
subplot(223)
plot(t_IR,Tech,'b','LineWidth',linewidth)
xlim([0 max(t_IR)])
xlabel('time (s)','FontSize', fontsize)
ylabel('Temperature (°C)','FontSize', fontsize)
title('Temperature ambiante')
xt = get(gca, 'XTick');
set(gca, 'FontSize', fontsize)
subplot(224)
semilogy(f,P1Tech,'b','LineWidth',linewidth)
hold on
semilogy(f(idxlogicfcomoun),P1Tech(idxlogicfcomoun),'ok','LineWidth',linewidth)
xlim([0 max(f)])
xlabel('Frequence (Hz)','FontSize', fontsize)
ylabel('Temperature (°C)','FontSize', fontsize)
title('FFT Temperature echantillon')
xt = get(gca, 'XTick');
set(gca, 'FontSize', fontsize)
0 Comments
Answers (1)
Sulaymon Eshkabilov
on 23 Aug 2019
Hi,
Without simulating your code, I'd suggest to try savitsky-golay filter: sgolayfilt() as a choice (1), as a choice (2) - bandpass/low/highpas butterworth with butter() and choice (3) - exponential filter.
Good luck.
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!