By discretizing transfer functions

In the following we want to show how to go from continuous (s) domain to digital (z) when working with transfer function models. We will keep working with the models from our previous closed loop example

Discretizing a transfer function model

Once we hace our continuous models is fairly simple to obtain their digital representation. We can insert them into the miir constructor specifying a sample frequency, for instance fs = 10 Hz, as follows

    Gd = miir(G,plist('fs',10));
    Hd = miir(H,plist('fs',10));
    OLGd = miir(OLG,plist('fs',10));

We want to compare if the discretization went right, but to do that we need to compute the response for the digital and the continuous apart since the resp method can not process inputs from different types. We can do the following

    %% Compare response
    
    pl = plist('f1',1e-3,'f2',5,'nf',100);
    
    % Digital
    rGd = resp(Gd,pl);
    rGd.setName('Gd');
    rHd = resp(Hd,pl);
    rHd.setName('Hd');
    rOLGd = resp(OLGd,pl);
    rOLGd.setName('OLGd');
    
    % Continuous
    rG = resp(G,pl);
    rG.setName('G');
    rH = resp(H,pl);
    rH.setName('H');
    rOLG = resp(OLG,pl);
    rOLG.setName('OLG');
    
    % Plot
    iplot(rGd,rG)
    iplot(rHd,rH)
    iplot(rOLGd,rOLG)
    

Power spectrum

Power spectrum

Power spectrum

Once the comparison is done, one is usually interested in the coefficients of the digital implemetation. These are directly accesible as, for example, Gd.a or Gd.b

    >> Gd.a
    
    ans =
    
    3.99874501384116      2.51248480253707e-06         -3.99874250135635
    
    >> Gd.b
    
    ans =
    
    1      0.000628121200622944        -0.999371878799377

The Delay strikes back

The current version of the toolbox (v2.0) is not able to translate a model with a delay into a digital filter. In such a case, the delay is ignored and a warning is thrown. You can repeat the previous example with the model with delay ('LISOFileDelay.fil') to obtain the following

Power spectrum