% ex 4 Single-pole noise shaping

k=2^7;
OSR = 5;
ampl = sqrt( (2*10^((-3.01-1)/10)))
sim('lab6ex4a')

sigview(sigIn4a, quantOut4a);grid on

sim('lab6a')

sigspectrum(quantOut3a, quantOut4a)
specOS = sigspectrum(quantOut4a);grid on
specOSIdealFiltered4a = specOS(1:513);
SNROS = max(specOSIdealFiltered4a)/(sum(specOSIdealFiltered4a)-max(specOSIdealFiltered4a))
SNROSdB = 10*log10(SNROS)

% Maloberti eq(6.16)
6.02*log2(k)+1.78-5.17+9.03*log2(32)