% find 95% containment BW of trapezoidal pulse as a function of ramp width
gamma = 0.95;
ff = -20:0.001:20;

aa = (0:0.001:0.5);
Bgamma = zeros(size(aa));

for nn = 1:length(aa)
    this_aa = aa(nn);
    PP = (1-this_aa)*sinc(this_aa*ff).*sinc((1-this_aa)*ff);
    
    Sr = cumsum(abs(PP).^2)/sum(abs(PP).^2);
    
    BgInd = find(Sr >= (1+gamma)/2, 1);
    Bgamma(nn) = 2* ff(BgInd);
end

plot(aa,10*Bgamma); % symbol period is 100ps => 1/T = 10MHz
grid on
xlabel('Ramp Width (a)');
ylabel(sprintf('%d-Percent Containment BW (MHz)', 100*gamma));
