This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Number of blocks in Generalized matrix or Generalized LTI model


N = nblocks(M)


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

Input Arguments


AGeneralized LTI model (genss or genfrd model), a Generalized matrix (genmat), or an array of such models.

Output Arguments


The number of Control Design Blocks in M. If a block appears multiple times in M, N reflects the total number of occurrences.

If M is a model array, N is an array with the same dimensions as M. Each entry of N is the number of Control Design Blocks in the corresponding entry of M.


Number of Control Design Blocks in a Second-Order Filter Model

This example shows how to use nblocks to examine two different ways of parametrizing a model of a second-order filter.

  1. Create a tunable (parametric) model of the second-order filter:


    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.

  2. Examine the number of tunable blocks in the model using nblocks.


    This command returns the result:

    ans =

    F has two tunable parameters, but the parameter wn appears five times—twice in the numerator and three times in the denominator.

  3. Rewrite F for fewer occurrences of wn.

    The second-order filter transfer function can be expressed as follows:


    Use this expression to create the tunable filter:

    F = tf(1,[(1/wn)^2 2*zeta*(1/wn) 1])
  4. Examine the number of tunable blocks in the new filter model.


    This command returns the result:

    ans =

    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.

Introduced in R2011a