You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorials/noise.md
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,4 +119,50 @@ Internally, a random number generator from [StableRNGs.jl](https://github.com/Ju
119
119
2. Multiple calls to the random number generator at the same time step all return the same number.
120
120
121
121
## Quantization
122
-
Not yet available.
122
+
123
+
A signal may be quantized to a fixed number of levels (e.g., 8-bit) using the [`Quantization`](@ref) block. This may be used to simulate, e.g., the quantization that occurs in a AD converter. Below, we have a simple example where a sine wave is quantized to 2 bits (4 levels), limited between -1 and 1:
124
+
```@example QUANT
125
+
using ModelingToolkit, ModelingToolkitSampledData, OrdinaryDiffEq, Plots
126
+
using ModelingToolkit: t_nounits as t, D_nounits as D
With the default option `midrise = true`, the output of the quantizer is always between `y_min` and `y_max` inclusive, and the number of distinct levels it can take is `2^bits`. The possible values are given by
154
+
```@example
155
+
bits = 2; y_min = -1; y_max = 1
156
+
collect(range(y_min, stop=y_max, length=2^bits))
157
+
```
158
+
Notably, these possible levels _do not include 0_. If `midrise = false`, a mid-tread quantizer is used instead. The two options are visualized below:
Note how the default mid-rise quantizer mode has a rise at the middle of the interval, while the mid-tread mode has a flat region (a tread) centered around the middle of the interval.
167
+
168
+
The default option `midrise = true` includes both end points as possible output values, while `midrise = false` does not include the upper limit.
0 commit comments