DSP Blockset
  Go to block:
    Search    Help Desk 

Specifying Matrix Dimensions

There is one important principle to keep in mind when working with matrices: The block determines the matrix dimension.

A matrix signal does not have an intrinsic dimension. The number of rows and columns is determined by the matrix size parameter settings of the block that receives the matrix as an input. (Depending on the block, the matrix size parameter may be called Matrix size, Number of rows, Number of columns, or Number of channels.)

Consider the simple model below.

When the Matrix Constant block generates the 3-by-4 matrix

Simulink represents the matrix as a simple ordered set of data,

If the Matrix size parameter in the Matrix To Workspace block is then set correctly, to [3 4], the constant matrix appears in the workspace with its correct 3-by-4 dimension.

However, if you set the Matrix size parameter to an alternate dimension, such as [4 3], the following matrix is output to the workspace:

Similarly, a Matrix size setting of [2 6] generates this output:

In general, any Matrix size setting in the Matrix To Workspace block that corresponds to a matrix with a total of 12 elements is allowable. This includes vector dimensions such as [1 12] and [12 1]. Only dimensions that do not correspond to a 12-element matrix generate an error.

Note
When Simulink's Vector Line Widths option is set, the value displayed next to a line carrying a matrix signal is the total number of elements in the matrix, 12 in this example.

Tracking Matrix Sizes

Because the matrix dimension is determined by the parameter setting in the individual receiving block, it is important to track the dimensions of matrix inputs and outputs. Make sure that the block receiving an M-by-N matrix has its matrix size parameter set appropriately. Examples of appropriate settings for an M-by-N matrix input are:

If the values you specify in these parameters do not agree with the actual input matrix size, errors or unexpected results can occur.

Scalars and Vectors

Almost all matrix-processing blocks (sample-based, frame-based, and general) handle scalars and vectors as special cases of matrices. A scalar input is a 1-by-1 matrix, and a length-N vector input is either a 1-by-N or N-by-1 matrix, depending on the input dimensions you enter in the block's matrix size parameter. As mentioned above, the distinction between a column vector and a row vector is made by the individual block based on this parameter setting; Simulink does not have separate data formats for row and column vectors.



[ Previous | Help Desk | Next ]