this
Description
The Simulation window contains an O-Matrix function that simulates values for the State vector . The Simulation window is an O-Matrix editor and as such you can perform standard editing commands within the window and using the Edit option from the O-Matrix menu bar. A specification of the Simulation function follows: ``` sim ```The return value is a double-precision matrix containing the simulated State vector values. The column dimension of the return value must be equal to the number of elements in the initial state estimate . The row dimension of the return value determines the number of time points in the simulation. The `(k,i)`th element of the return value is the `i`th element of the State vector at the `k`th time index.

Example
The following is a picture of the Simulation window for the example in EXAMPLE.KBF . ``` ```
``` function sim() begin ``` This line begins the definition of the O-Matrix `sim` function which has no parameters. ``` nk        = 10 amplitude = 20d0 ``` These two lines set the number of time points and the amplitude of the sine wave in the simulation. points and the ``` # east      = 50d0 + seq(nk) ``` This sets `east` to the double-precision column vector of length `nk`. The first value is `51`, the second value is `52` and so on. Note that, in O-Matrix, a binary operation between an integer value and a double-precision value has a double-precision result. ``` theta     = seq(nk) * 2 * PI / nk ``` This sets `theta` to the double-precision column vector of length `nk`. The first value is `2 pi / nk`, the second value is `4 pi / nk` and so on. ``` north     = amplitude * sin(theta) ``` This sets `north` to a double-precision column vector of length `nk`. The `k`th element is equal to ` amplitude sin(k 2 pi / nk)` ``` deast     = fill(1., nk, 1) ``` This sets `deast` to a single-precision column vector of length `nk` that has all its element equal to one. This is equal to the derivative of east with respect to time. (The single-precision data type is referred to as real in O-Matrix.) ``` dnorth    = amplitude * 2 * pi * cos(theta) / nk ``` This sets `dnorth` to a double-precision column vector of length `nk`. The `k`th element of `dnorth` is equal to the derivative of the function ` amplitude sin( (t - 50) 2 pi / nk)` with respect to `t` evaluated at `t = k`. ``` return [east, north, deast, dnorth] ``` This sets the return value of the `sim` function to a double-precision matrix with `nk` rows and `4` columns. The first column contains the values in `east`, the second `north`, the third `deast`, and the fourth `dnorth`. ``` end ``` This statement terminates the `sim` function definition.