You are here : matlabSignal Processingzp2sos

zp2sos() - Signal Processing

zp2sos converts a discrete-time zero-pole-gain
representation of a given digital filter to an equivalent second-order
section representation.[sos,g] = zp2sos(z,p,k) creates a matrix sos in
second-order section form with gain g equivalent
to the discrete-time zero-pole-gain filter represented by input arguments z, p,
and k. Vectors z and p contain
the zeros and poles of the filter's transfer function H(z),
not necessarily in any particular order. H(z)=k(z−z1)(z−z2)⋯(z−zn)(z−p1)(z−p2)⋯(z−pm)where n and m are the
lengths of z and p, respectively,
and k is a scalar gain. The zeros and poles must
be real or complex conjugate pairs. sos is an L-by-6
matrixsos=[b01b11b211a11a21b02b12b221a12a22⋮⋮⋮⋮⋮⋮b0Lb1Lb2L1a1La2L]whose rows contain the numerator and denominator coefficients bik and aik of
the second-order sections of H(z).H(z)=g∏k=1LHk(z)=g∏k=1Lb0k+b1kz−1+b2kz−21+a1kz−1+a2kz−2The number L of rows of the matrix sos is
the closest integer greater than or equal to the maximum of n/2
and m/2. [sos,g] = zp2sos(z,p,k,'order') specifies
the order of the rows in sos, where 'order' is'down', to order the sections so
the first row of sos contains the poles closest
to the unit circle'up', to order the sections so
the first row of sos contains the poles farthest
from the unit circle (default)[sos,g] = zp2sos(z,p,k,'order','scale') specifies
the desired scaling of the gain and the numerator coefficients of
all second-order sections, where 'scale' is'none', to apply no scaling (default)'inf', to apply infinity-norm scaling'two', to apply 2-norm scalingUsing infinity-norm scaling in conjunction with up-ordering
minimizes the probability of overflow in the realization. Using 2-norm
scaling in conjunction with down-ordering minimizes
the peak round-off noise.Note  

Infinity-norm and 2-norm scaling are appropriate only for direct-form II implementations.[sos,g] = zp2sos(z,p,k,'order','scale',zeroflag) specifies
whether to keep together real zeros that are the negatives of each
other instead of ordering them according to proximity to poles. Setting zeroflag to true keeps
the zeros together and results in a numerator with a middle coefficient
equal to zero. The default for zeroflag is false.sos = zp2sos(...) embeds
the overall system gain, g, in the first section, H1(z),
so that H(z)=∏k=1LHk(z)Note  

Embedding the gain in the first section when scaling a direct-form
II structure is not recommended and may result in erratic scaling.
To avoid embedding the gain, use ss2sos with
two outputs.


[sos,g] = zp2sos(z,p,k)[sos,g] = zp2sos(z,p,k,'order')[sos,g] = zp2sos(z,p,k,'order','scale')[sos,g] = zp2sos(z,p,k,'order','scale',zeroflag)sos = zp2sos(...)


Second-Order Sections from Zero-Pole-Gain ParametersOpen This Example
Design a 5th-order Butterworth lowpass filter using the function butter with output expressed in zero-pole-gain form. Specify the cutoff frequency to be one-fifth of the Nyquist frequency. Convert the result to second-order sections. Visualize the magnitude response.
[z,p,k] = butter(5,0.2);
sos = zp2sos(z,p,k)

sos =

    0.0013    0.0013         0    1.0000   -0.5095         0
    1.0000    2.0000    1.0000    1.0000   -1.0966    0.3554
    1.0000    2.0000    1.0000    1.0000   -1.3693    0.6926

Output / Return Value


Alternatives / See Also