% Reference for the steps below : Si446X AND FCC PART 90 COMPLIANCE 
% AT 450–470 MHZ, Silcon labs, AN866, Section 2.4.2. Emission Mask D 
function [] = Mask_D(PeakPwrdb)
PeakPowerWatts =10^(PeakPwrdb/10);

f1 = [0:0.05:5.625];
y1 = zeros(1,length(f1));

f2 = [5.675:0.05:12.5];
y2 = 7.27*(f2-2.88);

f3 = [12.55:0.05:50];
a1 = 50+10*log10(PeakPowerWatts);
a2 = 70;

if a1<a2
    k1 = a1;
else
    k1 = a2;
end

y3 = (ones(1,length(f3)))*k1;

freqLimPos = [f1 f2 f3];
maskLimPos = PeakPwrdb-[y1 y2 y3];

freqLimNeg = -1*flip(freqLimPos);
maskLimNeg = flip(maskLimPos);

freqLim = [freqLimNeg(1:end-1) freqLimPos]*(1e3);
maskLim = [maskLimNeg(1:end-1) maskLimPos];

plot(freqLim,maskLim);grid on;

end