Constant
Constant value.
blockType: Constant
Path in the library:
|
Description
Block Constant generates a valid or complex signal of constant value.
The block generates an output signal in the form of a scalar, vector, matrix or bus depending on the dimension of the parameter. Constant value.
| Read more about the types of tires. Custom tire types. |
The output signal of the block has the same dimensions and elements as the parameter Constant value.
Ports
Output
#
OUT_1
—
constant value
scalar | vector | matrix | bus
Details
A constant value in the form of a real or complex scalar, vector, matrix or bus. By default, block Constant outputs a signal whose dimension and data type are the same as the parameters Constant value.
| Data types |
|
| Complex numbers support |
Yes |
Parameters
Main
# Constant value — the value of the constant
Details
Set the output to a constant value of the block.
You can enter any value, including logical keywords. true and false.
| Default value |
|
| Program usage name |
|
| Tunable |
Yes |
| Evaluatable |
Yes |
#
Sample time —
the interval between the calculation steps
SampleTime (real number / vector of two real numbers)
Details
Sets the time interval during which the block output signal is Constant it may change during simulation (for example, due to parameter settings Constant value).
Default value inf indicates that the block output can never change. This value speeds up the simulation and the generated code, avoiding the need to recalculate the block output.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
Signal Attributes
#
Output data type —
type of output data
Inherit: auto | Float64 | Float32 | Float16 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Bool | Fixed-point | BusSignal
Details
Specify the type of output data. The type can be inherited or specified directly.
| Values |
|
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
#
Output fixed-point type —
the type of fixed-point output
Data type
Details
Specify the type of fixed-point output.
Dependencies
To use this parameter, set for the parameter Output data type meaning Fixed-point.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
#
Output bus type —
type of output bus
Data type
Details
Describes the type of bus that the unit outputs.
You can set the type yourself or enter the name of a variable that stores a type that has already been created in the workspace.
Dependencies
To use this parameter, set for the parameter Output data type meaning BusSignal.
Special case: zero bus
If for the block Constant the data type is selected BusSignal and the Constant value parameter is 0 or 0.0, a bus is formed at the output, all signals of which are zero, taking into account the basic types and dimensions specified in Output bus type. This is equivalent to calling convert(<Machine name>, 0).
Filling rules:
-
Scalars of integer types get the value
0the corresponding category (for example,Int8(0),Int64(0)); -
Scalars of real types —
0.0the appropriate format (for example,Float32(0.0),Float64(0.0)); -
Arrays/matrices are filled with zeros of the required shape (
fill(zero(T), dims)); -
Nested tires are filled recursively according to the same rules.
example
Let the type be defined in the workspace:
MyBus = BusSignal{(:s1, :s2, :s3), Tuple{Int64, Float64, Int8}, ((), (2,), (2, 2)), :MyBus}
In the Constant block, set:
-
Output data type =
BusSignal, -
Output bus type =
MyBus, -
Constant value =
0.
Then the output of the block will be:
(s1 = 0, s2 = [0.0, 0.0], s3 = Int8[0 0; 0 0])
If Constant value is specified by a named tuple (or bus object), then it must match the Output bus type structure; auto-zero padding applies only to values 0/0.0.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |