| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
Determining the Output Dimensions of Source Blocks Determining the Output Dimensions of Nonsource Blocks |
If a block can emit nonscalar signals, the dimensions of the signals that the block outputs depend on the block's parameters, if the block is a source block; otherwise, the output dimensions depend on the dimensions of the block's input and parameters.
A source block is a block that has no inputs. Examples of source blocks include the Constant block and the Sine Wave block. See the Sources table in the online Simulink block reference for a complete listing of Simulink source blocks. The output dimensions of a source block are the same as those of its output value parameters if the block's Interpret Vector Parameters as 1-D parameter is off (i.e., not selected in the block's parameter dialog box). If the Interpret Vector Parameters as 1-D parameter is on, the output dimensions equal the output value parameter dimensions unless the parameter dimensions are N-by-1 or 1-by-N. In the latter case, the block outputs a vector signal of width N.
As an example of how a source block's output value parameter(s) and Interpret Vector Parameters as 1-D parameter determine the dimensionality of its output, consider the Constant block. This block outputs a constant signal equal to its Constant value parameter. The following table illustrates how the dimensionality of the Constant value parameter and the setting of the Interpret Vector Parameters as 1-D parameter determine the dimensionality of the block's output.
| Constant Value | Interpret Vector Parameters as 1-D | Output |
|---|---|---|
scalar | off | one-element array |
scalar | on | one-element array |
1-by-N matrix | off | 1-by-N matrix |
1-by-N matrix | on | N-element vector |
N-by-1 matrix | off | N-by-1 matrix |
N-by-1 matrix | on | N-element vector |
M-by-N matrix | off | M-by-N matrix |
M-by-N matrix | on | M-by-N matrix |
Simulink source blocks allow you to specify the dimensions of the signals that they output. You can therefore use them to introduce signals of various dimensions into your model.
If a block has inputs, the dimensions of its outputs are, after scalar expansion, the same as those of its inputs. (All inputs must have the same dimensions, as discussed in Signal and Parameter Dimension Rules).
When creating a Simulink model, you must observe the following rules regarding signal and parameter dimensions.
All nonscalar inputs to a block must have the same dimensions.
A block can have a mix of scalar and nonscalar inputs as long as all the nonscalar inputs have the same dimensions. Simulink expands the scalar inputs to have the same dimensions as the nonscalar inputs (see Scalar Expansion of Inputs) thus preserving the general rule.
In general, a block's parameters must have the same dimensions as the corresponding inputs.
Two seeming exceptions exist to this general rule:
A block can have scalar parameters corresponding to nonscalar inputs. In this case, Simulink expands a scalar parameter to have the same dimensions as the corresponding input (see Scalar Expansion of Parameters) thus preserving the general rule.
If an input is a vector, the corresponding parameter can be either an N-by-1 or a 1-by-N matrix. In this case, Simulink applies the N matrix elements to the corresponding elements of the input vector. This exception allows use of MATLAB row or column vectors, which are actually 1-by-N or N-by-1 matrices, respectively, to specify parameters that apply to vector inputs.
Simulink converts vectors to row or column matrices and row or column matrices to vectors under the following circumstances:
If a vector signal is connected to an input that requires a matrix, Simulink converts the vector to a one-row or one-column matrix.
If a one-column or one-row matrix is connected to an input that requires a vector, Simulink converts the matrix to a vector.
If the inputs to a block consist of a mixture of vectors and matrices and the matrix inputs all have one column or one row, Simulink converts the vectors to matrices having one column or one row, respectively.
Note You can configure Simulink to display a warning or error message if a vector or matrix conversion occurs during a simulation. See Vector/matrix block input conversion for more information. |
Scalar expansion is the conversion of a scalar value into a nonscalar array of the same dimensions. Many Simulink blocks support scalar expansion of inputs and parameters. Block descriptions in the Simulink Reference indicate whether Simulink applies scalar expansion to a block's inputs and parameters.
Scalar expansion of inputs refers to the expansion of scalar inputs to match the dimensions of other nonscalar inputs or nonscalar parameters. When the input to a block is a mix of scalar and nonscalar signals, Simulink expands the scalar inputs into nonscalar signals having the same dimensions as the other nonscalar inputs. The elements of an expanded signal equal the value of the scalar from which the signal was expanded.
The following model illustrates scalar expansion of inputs. This model adds scalar and vector inputs. The input from block Constant1 is scalar expanded to match the size of the vector input from the Constant block. The input is expanded to the vector [3 3 3].

When a block's output is a function of a parameter and the parameter is nonscalar, Simulink expands a scalar input to match the dimensions of the parameter. For example, Simulink expands a scalar input to a Gain block to match the dimensions of a nonscalar gain parameter.
If a block has a nonscalar input and a corresponding parameter is a scalar, Simulink expands the scalar parameter to have the same number of elements as the input. Each element of the expanded parameter equals the value of the original scalar. Simulink then applies each element of the expanded parameter to the corresponding input element.
This example shows that a scalar parameter (the Gain) is expanded to a vector of identically valued elements to match the size of the block input, a three-element vector.

![]() | Displaying Signal Sources and Destinations | Checking Signal Ranges | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |