Create Tunable Second-Order Filter
This example shows how to create a parametric model of the second-order filter:
where the damping and the natural frequency are tunable parameters.
Define the tunable parameters using realp.
wn = realp('wn',3); zeta = realp('zeta',0.8);
wn and zeta are realp parameter objects, with initial values 3 and 0.8, respectively.
Create a model of the filter using the tunable parameters.
F = tf(wn^2,[1 2*zeta*wn wn^2]);
The inputs to tf are the vectors of numerator and denominator coefficients expressed in terms of wn and zeta.
F is a genss model. The property F.Blocks lists the two tunable parameters wn and zeta.
ans = struct with fields: wn: [1x1 realp] zeta: [1x1 realp]
You can examine the number of tunable blocks in a generalized model using nblocks.
ans = 6
F has two tunable parameters, but the parameter wn appears five times - Twice in the numerator and three times in the denominator.
To reduce the number of tunable blocks, you can rewrite F as:
Create the alternative filter.
F = tf(1,[(1/wn)^2 2*zeta*(1/wn) 1]);
Examine the number of tunable blocks in the new model.
ans = 4
In the new formulation, there are only three occurrences of the tunable parameter wn. Reducing the number of occurrences of a block in a model can improve the performance of calculations involving the model. However, the number of occurrences does not affect the results of tuning the model or sampling it for parameter studies.