Number of blocks in Generalized matrix or Generalized LTI model
N = nblocks(M)
returns
the number of Control Design Blocks in the Generalized
LTI model or Generalized matrix N
= nblocks(M
)M
.

AGeneralized LTI model ( 

The number of Control Design Blocks in If 
Number of Control Design Blocks in a SecondOrder Filter Model
This example shows how to use nblocks
to
examine two different ways of parametrizing a model of a secondorder
filter.
Create a tunable (parametric) model of the secondorder filter:
$$F\left(s\right)=\frac{{\omega}_{n}^{2}}{{s}^{2}+2\zeta {\omega}_{n}+{\omega}_{n}^{2}},$$
where the damping ζ and the natural frequency ω_{n} are tunable parameters.
wn = realp('wn',3); zeta = realp('zeta',0.8); F = tf(wn^2,[1 2*zeta*wn wn^2]);
F
is a genss
model
with two tunable Control Design Blocks, the realp
blocks wn
and zeta
.
The blocks wn
and zeta
have
initial values of 3 and 0.8, respectively.
Examine the number of tunable blocks in the model
using nblocks
.
nblocks(F)
This command returns the result:
ans = 6
F
has two tunable parameters, but the parameter wn
appears
five times—twice in the numerator and three times in the denominator.
Rewrite F
for fewer occurrences
of wn
.
The secondorder filter transfer function can be expressed as follows:
$$F\left(s\right)=\frac{1}{{\left(\frac{s}{{\omega}_{n}}\right)}^{2}+2\zeta \left(\frac{s}{{\omega}_{n}}\right)+1}.$$
Use this expression to create the tunable filter:
F = tf(1,[(1/wn)^2 2*zeta*(1/wn) 1])
Examine the number of tunable blocks in the new filter model.
nblocks(F)
This command returns the result:
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 performance time
of calculations involving the model. However, the number of occurrences
does not affect the results of tuning the model or sampling the model
for parameter studies.