Main Content


Generalized matrix with tunable parameters


Generalized matrices (genmat) are matrices that depend on tunable parameters (see realp). You can use generalized matrices for parameter studies. You can also use generalized matrices for building generalized LTI models (see genss) that represent control systems having a mixture of fixed and tunable components.


Generalized matrices arise when you combine numeric values with static blocks such as realp objects. You create such combinations using any of the arithmetic operators +, -, *, /, \, and ^. For example, if a and b are tunable parameters, the expression M = a + b is represented as a generalized matrix.

The internal data structure of the genmat object M keeps track of how M depends on the parameters a and b. The Blocks property of M lists the parameters a and b.

M = genmat(A) converts the numeric array or tunable parameter A into a genmat object.

Input Arguments


Static control design block, such as a realp object.

If A is a numeric array, M is a generalized matrix of the same dimensions as A, with no tunable parameters.

If A is a static control design block, M is a generalized matrix whose Blocks property lists A as the only block.



Structure containing the control design blocks included in the generalized LTI model or generalized matrix. The field names of Blocks are the Name property of each control design block.

You can change some attributes of these control design blocks using dot notation. For example, if the generalized LTI model or generalized matrix M contains a realp tunable parameter a, you can change the current value of a using:

M.Blocks.a.Value = -1;


Sampling grid for model arrays, specified as a data structure.

For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables.

Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array.

For example, suppose you create a 11-by-1 array of linear models, sysarr, by taking snapshots of a linear time-varying system at times t = 0:10. The following code stores the time samples with the linear models.

 sysarr.SamplingGrid = struct('time',0:10)

Similarly, suppose you create a 6-by-9 model array, M, by independently sampling two variables, zeta and w. The following code attaches the (zeta,w) values to M.

[zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>)
M.SamplingGrid = struct('zeta',zeta,'w',w)

When you display M, each entry in the array includes the corresponding zeta and w values.

M(:,:,1,1) [zeta=0.3, w=5] =
  s^2 + 3 s + 25

M(:,:,2,1) [zeta=0.35, w=5] =
  s^2 + 3.5 s + 25

For model arrays generated by linearizing a Simulink® model at multiple parameter values or operating points, the software populates SamplingGrid automatically with the variable values that correspond to each entry in the array. For example, the Simulink Control Design™ commands linearize (Simulink Control Design) and slLinearizer (Simulink Control Design) populate SamplingGrid in this way.

Default: []


System name, specified as a character vector. For example, 'mat_1'. When you convert a static control design block such as tunableSurface to a generalized matrix using genmat(blk), the Name property of the block is preserved.

Default: ''


Generalized Matrix With Two Tunable Parameters

This example shows how to use algebraic combinations of tunable parameters to create the generalized matrix:


where a and b are tunable parameters with initial values –1 and 3, respectively.

  1. Create the tunable parameters using realp.

     a = realp('a',-1);
     b = realp('b',3);
  2. Define the generalized matrix using algebraic expressions of a and b.

    M = [1 a+b;0 a*b]

    M is a generalized matrix whose Blocks property contains a and b. The initial value of M is M = [1 2;0 -3], from the initial values of a and b.

  3. (Optional) Change the initial value of the parameter a.

    M.Blocks.a.Value = -3;
  4. (Optional) Use double to display the new value of M.


    The new value of M is M = [1 0;0 -9].

Version History

Introduced in R2011a