I have to design an 8th-order IIR filter with the following transfer function magnitude response as a specification:

I use "ellip" function from matlab to calculate the unquantised coefficient set:

Then i implement the filter using a cascade of second-order sections using "tf2sos" matlab function:

And then i quantize these coefficients:

After all these steps i take the two matrices below:

I choose the filter representation for every second-order instance to be like below (Direct Form 2):

- circle with "X" is a multiplication
- circle with "Σ" is an addition
- and the triangle is a delay element
After that i have done all of these i write some matlab code to model the structure above:
%Implementation of a second-order filter structure function[y,state,pointer]=Second_Order(x,a,b,state,pointer) %The filter routine when fed with an input sample produce one output %sample each time it is called %x=input value %a=array containing feedback coefficients[1,a1,a2] %b=array containing feed forward coefficients[b0,b1,b2] %state=array(of length 2) containing old input values %y=output value %compute output value y=b(1)*x+state(pointer+1); pointer=rem(pointer+1,2); %update pointer in modulo form %Update states state(pointer+1)=b(2)*x-a(2)*y+state(pointer+1); pointer=rem(pointer+1,2); %Overwrite oldest sum with b(N-1).x state(pointer+1)=b(3)*x-a(3)*y; pointer=rem(pointer+1,2);%Increment pointer modulo-(N-1) At the end, and the point that i don't know how to do it properly is how i can display the impulse and step response of the whole filter and not for every second order section.
For example if i write something like that, i think i take the impulse response of the first second order section. How i can take the impulse resonse of the whole system?
%Initialization [b,a]=ellip(4,1.3,60,2*[0.2,0.3]); [sos,q]=tf2sos(b,a); sosq=Quantize('round',sos,2^6); bf=sosq(1,1:3); af=sosq(1,4:6); %impulse invariant design impsv=zeros([1,2]);%impulse response state variable stpsv=zeros([1,2]);%step response state variable len=20; % run length impy=zeros([1,len]);%impulse response result stpy=zeros([1,len]);% step response result impp=0; stpp=0; % Simulation of filter operation x=1; for k=1:len [impy(k),impsv,impp]=Second_Order(x,af,bf,impsv,impp); [stpy(k),stpsv,stpp]=Second_Order(1,af,bf,stpsv,stpp); x=0; end