To show some of the possibilities of the toolbox to model digital system we introduce usual notation for a closed loop model

Closed Loop

In our example we will assume that we know the pzmodel of the filter, H, and the open loop gain (OLG). These are related with the closed loop gain (CLG) by the following equation



We want to determine H and CLG. We would also like to find a digital filter for H, but we will deal with this in the following section.

Loading the starting models

Imagine that we have somehow managed to find the following model for OLG

Key Value

GAIN

4e6

POLES

1e-6

then we can create a pzmodel with these parameters as follows

    OLG = pzmodel(4e6,1e-6,[],'OLG')
    ---- pzmodel 1 ----
    name: OLG
    gain: 4000000
    delay: 0
    iunits: []
    ounits: []
    pole 001: (f=1e-06 Hz,Q=NaN)
    -------------------

To introduce the second model, the one describing H, we will show another feature of the pzmodel constructor. We will read it from a LISO file, since this contructor accepts this files as inputs. We can then type

    H = pzmodel('LISOFile.fil')
    M:   load file: LISOFile.fil
    ---- pzmodel 1 ----
    name: opd_digi_100_iir1
    gain: 1000000000
    delay: 0
    iunits: []
    ounits: []
    pole 001: (f=1e-06 Hz,Q=NaN)
    pole 002: (f=1e-06 Hz,Q=NaN)
    zero 001: (f=0.001 Hz,Q=NaN)
    -------------------
and we see how the constructor recognizes and translates the poles in the file. The model gets the name from the file but we can easily change it to have the the name of our model
    H.setName;
According to our previous definition we can get the plant by dividing the OLG by H. We can do so directly when dealing with pzmodel objects since multiplication and division are allowed for these objects, then
    G = OLG/H
    ---- pzmodel 1 ----
    name: (OLG./H)
    gain: 0.0040111
    delay: 0
    iunits: []
    ounits: []
    pole 001: (f=1e-06 Hz,Q=NaN)
    pole 002: (f=0.001 Hz,Q=NaN)
    zero 001: (f=1e-06 Hz,Q=NaN)
    zero 002: (f=1e-06 Hz,Q=NaN)
    -------------------
which we need to simplify to get rid of cancelling poles and zeros. We also set the model name here.
    G.setName;
    G.simplify
    M:   cancelling pole (f=1e-06 Hz,Q=NaN) and zero (f=1e-06 Hz,Q=NaN)
    ---- pzmodel 1 ----
    name: simplify((OLG./H))
    gain: 0.0040111
    delay: 0
    iunits: []
    ounits: []
    pole 001: (f=0.001 Hz,Q=NaN)
    zero 001: (f=1e-06 Hz,Q=NaN)
    -------------------
The CLG requires more than a simple multiplication or division between models and we will not be able to derive a pzmodel for it. However, we can evaluate the response of this object as follows
    pl = plist('f1',1e-3,'f2',5,'nf',100);
    CLG = 1/(1-resp(OLG,pl));
    CLG.setName;
which gives us an AO that we can plot
Closed Loop response

Fine, but my (real) system has a delay...

You can now repeat the same procedure but loading a H model with a delay from the LISO file 'LISOFileDelay.fil'

    H = pzmodel('LISOFileDelay.fil')
    M:   load file: LISOFileDelay.fil
    ---- pzmodel 1 ----
    name: LISOfileDelay
    gain: 4000000
    delay: 0.0174
    iunits: []
    ounits: []
    pole 001: (f=1e-06 Hz,Q=NaN)
    -------------------

you will see how the delay is correctly handled, meaning that it is added when we multiply two models and substracted if the models are divided.

Closed Loop response