Converts zeros, poles and gain to cascade form filter coefficients.
ZP2CAS(z, p, k, "flag")
z 
 
A series, the zeros. 

p 
 
A series, the poles. 

k 
 
Optional. A scalar, the gain. Defaults to 1.0. 

"flag" 
 
Optional. A string, the stage ordering flag:

A series, the system coefficients in cascaded biquad form.
z = {0.0, 2.0};
p = {0.5, 0.2};
k = 1.0;
c = zp2cas(z, p, k);
c == {1, 1, 2, 0, 0.7, 0.1};
The 2nd order cascade filter coefficients represent the following Z transform:
ZP2CAS converts the zeros, poles and gain of a discrete system to cascade coefficient form where the coefficients represent the following Z transform:
or:
where G is the system gain, b_{k} and a_{k} are the filter coefficients for the k^{th} stage.
The cascade filter coefficients are returned as a single column series with the coefficients in the following order:
{G, b_{10}, b_{11}, b_{12}, a_{11}, a_{12}, b_{20}, b_{21}, b_{22}, a_{21}, a_{22}, ... , b_{N0}, b_{N1}, b_{N2}, a_{N1}, a_{N2}}
CAS2ZP also works for analog cascade coefficients. In this case, the cascade system function becomes:
or equivalently:
To yield real coefficients, the zeros and poles must occur in complex conjugate pairs or be real.
The stages are ordered such that the poles of each stage are closer to the unit circle than the previous stage. The zeros of each stage are chosen to be closest to the poles of the same stage.
If "flag" == "down", the stages are reversed.
See CAS2ZP to convert cascade coefficients to zeros, poles and gain terms.