Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Constant - Generate constant value

Library

Sources

Description

The Constant block generates a real or complex constant value. The block generates scalar, vector, or matrix output, depending on the dimensionality of the Constant value parameter and the setting of the Interpret vector parameters as 1-D parameter. Also, the block can generate either a sample-based or frame-based signal, depending on the setting of the Sampling mode parameter.

The output of the block has the same dimensions and elements as the Constant value parameter. If you specify a vector for this parameter, and you want the block to interpret it as a vector, select the Interpret vector parameters as 1-D parameter. Otherwise, the block treats the Constant value parameter as a matrix.

Data Type Support

By default, the Constant block outputs a signal whose data type and complexity are the same as that of the block's Constant value parameter. However, you can specify the output to be any data type supported by Simulink software, including fixed-point and enumerated data types. The Enumerated Constant block may be more convenient than the Constant block for outputting a constant enumerated value.

For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink.

Parameters and Dialog Box

The Main pane of the Constant block dialog box appears as follows:

Opening this dialog box causes a running simulation to pause. See Changing Source Block Parameters During Simulation.

The Signal Attributes pane of the Constant block dialog appears as follows:

Show data type assistant

Display the Data Type Assistant.

Settings

The Data Type Assistant helps you set the Output data type parameter.

See Specifying Block Output Data Types for more information.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Constant value

Specify the constant value output of the block.

Settings

Default: 1

Minimum: value from the Output minimum parameter

Maximum: value from the Output maximum parameter

Command-Line Information

See Block-Specific Parameters for the command-line information.

Interpret vector parameters as 1-D

Select this check box to output a vector of length N if the Constant value parameter evaluates to an N-element row or column vector.

Settings

Default: On

On

Outputs a vector of length N if the Constant value parameter evaluates to an N-element row or column vector. For example, the block outputs a matrix of dimension 1-by-N or N-by-1.

Off

Does not output a vector of length N if the Constant value parameter evaluates to an N-element row or column vector.

If you clear this check box, you can interact with the Sampling mode parameter.

Dependencies

This parameter enables Sampling mode.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Sampling mode

Specify whether the output signal is Sample based or Frame based.

Settings

Default: Sample based

Sample based

The output signal is sample-based.

Frame based

The output signal is frame-based.

Tips

To generate frame-based signals, you must have the Signal Processing Blockset™ product installed.

For more information, see Sample-Based Signals and Frame-Based Signals in the Signal Processing Blockset User's Guide.

Dependencies

Clearing Interpret vector parameters as 1-D enables this parameter.

Selecting Sample based enables the following parameter:

Selecting Frame based enables the following parameter:

Command-Line Information

See Block-Specific Parameters for the command-line information.

Sample time

Specify the interval between times that the Constant block output can change during simulation (for example, due to tuning the Constant value parameter).

Settings

Default: inf

This setting indicates that the block output can never change. This setting speeds simulation and generated code by avoiding the need to recompute the block output.

See How to Specify the Sample Time in the online documentation for more information.

Dependency

Sampling mode enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Frame period

Specify the interval between frames that the Constant block output can change during simulation (for example, due to tuning the Constant value parameter).

Settings

Default: inf

Dependency

Sampling mode enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor.

Settings

Default: Off

On

Locks the output data type setting for this block.

Off

Allows the Fixed-Point Tool and the Fixed-Point Advisor to change the output data type setting for this block.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.

Output minimum

Specify the minimum value that the block should output.

Settings

Default: []

The default value, [], is equivalent to -Inf.

Simulink software uses this value to perform:

Tip

This number must be a double scalar value.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output maximum

Specify the maximum value that the block should output.

Settings

Default: []

The default value, [], is equivalent to Inf.

Simulink software uses this value to perform:

Tip

This number must be a double scalar value.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output data type

Specify the output data type.

Settings

Default: Inherit: Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block), Inherit: Inherit from 'Constant value' (Constant block), Inherit: Inherit via back propagation (Data Type Conversion block), Inherit: Same as input (Saturation block)

Inherit: Inherit via internal rule

This option appears for some blocks. Simulink software chooses a combination of output scaling and data type that requires the smallest amount of memory consistent with accommodating the calculated output range and maintaining the output precision of the block and with the word size of the targeted hardware implementation specified for the model. If the Device type parameter on the Hardware Implementation configuration parameters pane is set to ASIC/FPGA, Simulink software chooses the output data type without regard to hardware constraints. Otherwise, Simulink software chooses the smallest available hardware data type capable of meeting the range and precision constraints. For example, if the block multiplies an input of type int8 by a gain of int16 and ASIC/FPGA is specified as the targeted hardware type, the output data type is sfix24. If Unspecified (assume 32-bit Generic), i.e., a generic 32-bit microprocessor, is specified as the target hardware, the output data type is int32. If none of the word lengths provided by the target microprocessor can accommodate the output range, Simulink software displays an error message in the Simulation Diagnostics Viewer.

Inherit: Inherit from 'Constant value'

Use data type of Constant value parameter. This option appears for some blocks.

Inherit: Inherit via back propagation

Use data type of the driving block.

Inherit: Same as input

Use data type of sole input signal. This option appears for some blocks.

Inherit: Same as first input

Use data type of first input signal. This option appears for some blocks.

Inherit: Same as accumulator

Output data type is the same as accumulator data type. This option appears for some blocks.

double

Output data type is double.

single

Output data type is single.

int8

Output data type is int8.

uint8

Output data type is uint8.

int16

Output data type is int16.

uint16

Output data type is uint16.

int32

Output data type is int32.

uint32

Output data type is unt32.

fixdt(1,16,0)

Output data type is fixed point fixdt(1,16,0).

fixdt(1,16,2^0,0)

Output data type is fixed point fixdt(1,16,2^0,0).

Enum: <class name>

Use an enumerated data type, for example, Enum: BasicColors. This option appears for some blocks.

<data type expression>

Use a data type object, for example, Simulink.NumericType.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying Block Output Data Types in the Simulink User's Guide for more information.

Mode

Select the category of data to specify.

Settings

Default: Inherit (Constant, Data Type Conversion, Discrete Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch), Built in (Logical Operator, Relational Operator)

Inherit

Inheritance rules for data types. Selecting Inherit enables a second menu/text box to the right. The following list is the possible values, which can vary by block:

  • Inherit from 'Constant value' (Constant block default)

  • Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block default)

  • Inherit via back propogation (Data Type Conversion block default)

  • auto (Inport, Outport block default)

  • Logical (see Configuration Parameters: Optimization)

  • Same as first input

  • Same as input (Saturation block default)

  • Same as accumulator

Built in

Built-in data types. Selecting Built in enables a second menu/text box to the right. The following list is the possible values, which can vary by block:

  • double (Constant, Data Type Conversion, Discrete-Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch block default)

  • single

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

  • boolean (Logical Operator, Relational Operator block default)

Fixed point

Fixed-point data types.

Enumerated

Enumerated data types. This option is available on some blocks. Selecting Enumerated enables a second menu/text box to the right. The following list is the possible values, which can vary by block:

  • <class name>

Expression

Expressions that evaluate to data types. Selecting Expression enables a second menu/text box to the right. The following list is the possible values, which can vary by block:

  • <data type expression>

Dependency

Clicking the Show data type assistant button enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Using the Data Type Assistant in the Simulink User's Guide.

Signedness

Specify whether you want the fixed-point data as signed or unsigned.

Settings

Default: Signed

Signed

Specify the fixed-point data as signed.

Unsigned

Specify the fixed-point data as unsigned.

Dependencies

Selecting Mode > Fixed point enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Word length

Specify the bit size of the word that holds the quantized integer.

Settings

Default: 16

Minimum: 0

Maximum: 32

Large word sizes represent large values with greater precision than small word sizes.

Dependencies

Selecting Mode > Fixed point enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

Settings

Default: Best precision (Constant), Binary point (Data Type Conversion, Discrete-Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch), Integer (Logical Operator, Relational Operator)

Binary point

Specify binary point location.

Slope and bias

Enter slope and bias.

Best precision

Specify best-precision values. This option appears for some blocks.

Integer

Specify integer. This setting has the same result as specifying a binary point location and setting fraction length to 0. This option appears for some blocks.

Dependencies

Selecting Mode > Fixed point enables this parameter.

Selecting Binary point enables:

Selecting Slope and bias enables:

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Fraction length

Specify fraction length for fixed-point data type.

Settings

Default: 0

Binary points can be positive or negative integers.

Dependencies

Selecting Scaling > Binary point enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Slope

Specify slope for the fixed-point data type.

Settings

Default: 2^0

Specify any positive real number.

Dependencies

Selecting Scaling > Slope and bias enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Bias

Specify bias for the fixed-point data type.

Settings

Default: 0

Specify any real number.

Dependencies

Selecting Scaling > Slope and bias enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Characteristics

Direct Feedthrough

N/A

Sample Time

Specified in the Sample time parameter

Scalar Expansion

No

Dimensionalized

Yes

Multidimensionalized

Yes

Zero-Crossing Detection

No

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS