

results=[];

fout=144.39
attenuation=60
for sysclock=320 %$120:380

fund=min(fout,sysclock-fout)
im=[fund sysclock-fund sysclock+fund sysclock*2-fund sysclock*2+fund]
pim=20*log10( abs(  sinc(im/sysclock) ))

fc=10

fdesired_mask=im==fout
fundesired_mask=1-fdesired_mask
pdesired=pim*fdesired_mask'
%(pim.*(1-fdesired_mask))

df=abs(im-fout)    % difference between test frequency and center frequency 

%dp=(pim-pdesired)+(1-fdesired_mask)*attenuation
atten_req=(pim-pdesired)+(fundesired_mask)*attenuation  % dB attenuation needed for BPF
p_req=10.^(-atten_req/10)
nf=(df./fc)               % normalized frequency 
n_req=(log10((1-p_req)./p_req+fdesired_mask)./(2*log10(nf)))
n_max=max(n_req)

results=[results;[sysclock n_max]];
end

fs=sysclock

f=1:fs*2.5;

gain=20*log10( abs(  sinc(f/fs) ));
plot( f,gain )
ylim([-40 0])

plot(results(:,1),results(:,2))
ylim([0 10])
results

