# How to eliminate matched filter background?

The question

My goal is to detect an unknown frequency $f_1$ with a mixer and a matched filter. My simulation shows (below) that I correctly identify the 50 kHz external signal - but it also produces extra signals, some of which I have as circled in red.

As you can see, the extra signal is significant - as big as 20 % of the peak detection. It also interferes with the height of the peak, which is critical for my application. These are my questions:

1. Where does this come from?
2. How to prevent it?

Background

There is a signal $s_1(t)=A_1\cos(2\pi f_1 t +\phi_1)$ with an unknown frequency $f_1$, phase $\phi_1$, and amplitude $A_1$. In this simulation, $f_1$ is between 45 and 55 kHz, or simply $45 < f_1 < 55$.

The scheme is to multiply $s_1(t)$ with a signal $n_{ramp}(t)$ that ramps linearly from 45 to 55 kHz over 10 seconds. When the two signals have the same frequency, a dc peak will be produced by the cosine product rule. Then, the signal is fed into a matched filter and a peak is produced corresponding to the external signal.

My scheme is summarized by this diagram:

Code

I've made a MWE in octave:

clear all;
close all;

%Constants
sampleRate=0.00005;
time=0:sampleRate:10;
frequency=45+time;
phase=45*time + 0.5*time.^2;

% Signals
s1=cos(2*pi*50*time+pi/3);
n_ramp=cos(2*pi*phase);
s2=s1.*n_ramp;
s3=filter(fir1(500, 16*sampleRate*2,'low'),1,s2); %Low Pass Filter

% Matched Filter
r1=cos(2*pi*52*time);
ref00=r1.*n_ramp;
r2=cos(2*pi*52*time+pi/2);
ref05=r2.*n_ramp;
matched_filter=fft(ref00+i*ref05);

% Apply Filter and Plot
filtering=matched_filter.*fft(s3);
sout=shift(abs(ifft(filtering)),3/sampleRate);

figure
plot(frequency,sout/max(sout),'b-','LineWidth',1);
axis([45 55 0 1.1])
xlabel('Frequency, kHz', "fontsize", 15)
ylabel('Amplitude, a.u.', "fontsize", 15)
set(gca, "linewidth", 2, "fontsize", 12)


Thoughts

The extra signal detected is not noise; there is no noise in my simulation. Where does it come from? How can I prevent it from messing with the amplitude of my output?

• Interesting approach. The signal $n_{\rm ramp}$ is not a cosine wave, because the frequency is not constant. So there won't be a 'dc peak' for very long. The chirp signal probably "leaks" to get that background level. How precise do you need the frequency estimate to be? Would having two constant-frequency steps instead of $n_{\rm ramp}$ do just as well? – Peter K. Jul 10 '17 at 13:04
• @PeterK. If it was just two frequency constant steps, it would only detect two external frequencies. Hence the linear increasing frequency – axsvl77 Jul 10 '17 at 13:26
• Understood. That's why I asked how precisely you need to know the frequency. Is two enough (no)? Is ten enough? 100? 1000? And all of this will probably need to be redone once you figure out what noise you're going to have to deal with. – Peter K. Jul 10 '17 at 13:28