ComparewIntConstant Icon
Compare.ComparewIntConstant
ComparewIntConstant()Checks whether an integer input signal (u) is approximately equal to a specified threshold.
Variables
u: Integer input signaly: Real output (1.0 if |u - threshold| < tolerance, 0.0 otherwise)threshold: Threshold value to compare withtolerance: Tolerance band for the check (default: 1e-5)
Description
A real-valued parameter (threshold) sets the reference value for comparison. A second parameter (tolerance) defines an acceptable range around the threshold within which the input is considered equal.
Usage
PrimitiveComponents.Compare.ComparewIntConstant(threshold, tolerance=1e-5)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
threshold | – | ||
tolerance | – | 0.00001 |
Connectors
u- This connector represents an integer signal as an input to a component (IntegerInput)y- This connector represents a real signal as an output from a component (RealOutput)
Behavior
\[ \begin{align} y\left( t \right) &= ifelse\left( \left| - \mathtt{threshold} + u\left( t \right)\right| < \mathtt{tolerance}, 1, 0 \right) \end{align} \]
Source
"""
ComparewIntConstant()
Checks whether an integer input signal (u) is approximately equal to a specified threshold.
# Variables
- `u`: Integer input signal
- `y`: Real output (1.0 if |u - threshold| < tolerance, 0.0 otherwise)
- `threshold`: Threshold value to compare with
- `tolerance`: Tolerance band for the check (default: 1e-5)
# Description
A real-valued parameter (threshold) sets the reference value for comparison. A second parameter
(tolerance) defines an acceptable range around the threshold within which the input is considered equal.
"""
component ComparewIntConstant
u = Dyad.IntegerInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -20, "y1": 480, "x2": 20, "y2": 520, "rot": 0},
"diagram": {"iconName": "default", "x1": -40, "y1": 480, "x2": 0, "y2": 520, "rot": 0}
},
"tags": []
}
}
y = Dyad.RealOutput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": 1000, "y1": 480, "x2": 1040, "y2": 520, "rot": 0},
"diagram": {"iconName": "default", "x1": 1000, "y1": 480, "x2": 1040, "y2": 520, "rot": 0}
},
"tags": []
}
}
parameter threshold::Real()
parameter tolerance::Real = 1e-5
relations
y = ifelse((abs(u - threshold) < tolerance), float_sym(1.0), float_sym(0.0))
metadata {
"Dyad": {
"labels": [
{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0},
{"label": " $(threshold)", "x": 500, "y": -150, "rot": 0}
],
"icons": {"default": "dyad://PrimitiveComponents/EqualThreshold.svg"}
}
}
end
Flattened Source
"""
ComparewIntConstant()
Checks whether an integer input signal (u) is approximately equal to a specified threshold.
# Variables
- `u`: Integer input signal
- `y`: Real output (1.0 if |u - threshold| < tolerance, 0.0 otherwise)
- `threshold`: Threshold value to compare with
- `tolerance`: Tolerance band for the check (default: 1e-5)
# Description
A real-valued parameter (threshold) sets the reference value for comparison. A second parameter
(tolerance) defines an acceptable range around the threshold within which the input is considered equal.
"""
component ComparewIntConstant
u = Dyad.IntegerInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -20, "y1": 480, "x2": 20, "y2": 520, "rot": 0},
"diagram": {"iconName": "default", "x1": -40, "y1": 480, "x2": 0, "y2": 520, "rot": 0}
},
"tags": []
}
}
y = Dyad.RealOutput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": 1000, "y1": 480, "x2": 1040, "y2": 520, "rot": 0},
"diagram": {"iconName": "default", "x1": 1000, "y1": 480, "x2": 1040, "y2": 520, "rot": 0}
},
"tags": []
}
}
parameter threshold::Real()
parameter tolerance::Real = 1e-5
relations
y = ifelse((abs(u - threshold) < tolerance), float_sym(1.0), float_sym(0.0))
metadata {
"Dyad": {
"labels": [
{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0},
{"label": " $(threshold)", "x": 500, "y": -150, "rot": 0}
],
"icons": {"default": "dyad://PrimitiveComponents/EqualThreshold.svg"}
}
}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses