How MATLAB calculates matched filter gain Here is a bunch of code from MATLAB documentation: Designing a Basic Monostatic Pulse Radar:

wav = phased.RectangularWaveform(...
    'PulseWidth',1/pulseBandwidth,...
    'PRF',PRF,...
    'SampleRate',Fs);
matchingcoeff = getMatchedFilter(wav);

hmf = phased.MatchedFilter(...
    'Coefficients',matchingcoeff,...
    'GainOutputPort',true);


[rx_pulses, mfgain] = step(hmf,rx_pulses);


How MATLAB calculates the mfgain (matched filter gain)? Any formula for that?
Matched filter gain is calculated as (in dB):


$G_{dB} = 10 \cdot \log_{10}(L)$,


where $L$ - is filter length. It's maximum possible SNR improvement that filter can provide.

Try this formula and compare result with MATLAB one. I suppose it will be the same.