I have to compare the response of an 8th order IIR filter and its equivalent 4 stage cascaded biquad structure. A sinusoidal signal is given as input to both the systems and the output responses are plotted and the difference between the outputs of two cases are plotted.Why there is an error of the range of 15 between the output of both the cases .Code is as follows:
%%%input signal
fs=20000;
t=0:1/fs:1-1/fs;
input=2^15.*sin(2*pi*400*t);
len=length(input);%%%number of samples of the input signal
%%%BPF spec
bpf_order=8; %%%order of BPF (Ideal case)
nyquist_frequency=fs/2;%%%Nyquist frequency
lower_cutoff_freq_ch1=300/nyquist_frequency;
upper_cutoff_freq_ch1=400/nyquist_frequency;
[num_coeff_ch1 den_coeff_ch1]=butter(bpf_order/2,[lower_cutoff_freq_ch1
upper_cutoff_freq_ch1])
output=filter(num_coeff_ch1,den_coeff_ch1,input);
[sos1 G1]=tf2sos(num_coeff_ch1,den_coeff_ch1);
num_coeff_ch1=sos1((1:bpf_order/2),(1:3));
den_coeff_ch1=sos1((1:bpf_order/2),(4:6));
no_of_sos=bpf_order/2;
bpf_output=input.*G1;
for ite=1:(no_of_sos)
bpf_output=filter(num_coeff_ch1(ite,:),den_coeff_ch1(ite,:),bpf_output);
end
figure()
plot(output)
hold on
plot(bpf_output,'c*');
signals=[output ;bpf_output];
error=signals(1,:)-signals(2,:);
figure()
plot(error)