# Loudspeaker crossover network using Sallen key filters (MATLAB transfer functions)

I am currently trying to model an active Linkwitz-Riley crossover network using cascaded Sallen-Key lowpass (LP) and highpass (HP) filters.

I can get plots simulated in MATLAB of both transfer functions, however using the same RC values for the HP and LP I thought would cause both to have the same cutoff frequency so that when put together they would cause no gain loss across the system.

However, this is not the case seen. I have used the transfer functions explained in Texas Instruments paper, however they are adapted to not include resistors 3 and 4: http://www.ti.com/lit/an/sloa024b/sloa024b.pdf

I am currently just using the transfer function for a singular Sallen-Key filter in the hopes of once this is sorted I can then simply cascade them.

The MATLAB code for the transfer functions is as follows :

function H = transferLP(R,C,f)
s = 1j.*2.*pi.*f;
RC = R.*C;
H = 1./((s.^2).*(RC.^2) + (s.*(RC + RC + RC)) + 1);
end

function H = transferHP(R,C,f)
s = 1j.*2.*pi.*f;
RC = R.*C;
H = ((s.^2).*(RC.^2))./((s.^2).*(RC.^2) + (s.*(RC + RC + RC)) + 1);
end


Taking the real part (real(h)) of the result of these functions should obtain the magnitude information while the imaginary part (imag(h)) should contain the phase information.

f = frequency vector R = resistor values C = capacitor values (Keep R & C the same i know you can change them individually)

The plot I get out for the magnitude is as follows.

As a side note I was also wondering why the gain dips below 0; is this a ripple in the stop band because I'm using a second order filter?

Thanks for the help in advance.