The Measurement window contains an

meas(

`, `

`, `

`, `

`, `

`)`

The integer scalar ```
```

The input value of *h* (*x* )
*k* *k*

It is as a double-precision column vector with
length equal to the number of columns in the
file specified below
```
```

The input value of *h*

with respect the State vector; i.e.,
*d*
-- *h* (*x* )
*dx* *k* *k*
*k*

It is a double-precision matrix with the same number of rows as
```
```

The input value of *R*
*k*

the variance of the noise in the measurements.
It is a double-precision
If one of the elements of the output value of

`-1d300`

or `-1e300`

in the Data window, you should use the same representation
in the Measurement function to avoid roundoff error problems.
The following is a picture of the Measurement window for the example in

```
```

```
```

# location of the two shore stations

local A = {0., -100.}

local B = {0., +100.}

These statements define the variables *A*

and *B*

to be the locations of the two shore stations.
Because they begin with the word `local`

,
the variables *A*

and *B*

can be accessed anywhere within the
Measurement window and only within the Measurement window.
Because they appear outside the `meas`

function,
they are only executed once, instead of every time the function `meas`

is called.
```
```

function meas(k, xk, hk, dhk, Rk) begin

This line begins the definition of the O-Matrix `meas`

function
and specifies the name its parameters will have inside of the function.
```
```

# location of the ship

S = xk(1::2)

This statement sets *S*

to
the subvector consisting of
the first two elements of the vector *xk*

.
This is the ship position that corresponds to the
State vector value being *xk*

.
```
```

# model for range to stations 1 and 2

# is the Eculidean distance to the ship

r1 = |S - A|

r2 = |S - B|

hk = {r1, r2}

The first statement sets *r*1

to the Euclidean distance between the
ship location and the shore station *A*

.
This is equal to the square root of the sum of the squares of the
vector difference between *S*

and *A*

.
The second statement sets *r*2

to the Euclidean distance between the
ship location and the shore station *B*

.
The third statement assign *hk*

to the
Measurement function value corresponding to State vector being *xk*

.
```
```

# derivative of range model with

# respect to ship location

dr1 = (S - A)' / r1

dr2 = (S - B)' / r2

These statements set *dr*1

and *dr*2

to the derivative of *r*1

and *r*2

with respect to ship position.
The values *r*1

and *r*2

are scalars,
so there derivatives are row vectors
(note that `'`

is the transpose operator in O-Matrix).
The value *r*1

can be written as
__________________________________________
*r*1(*S*) = \/ (*ship*(1) - *A*(1))^2 + (*ship*(2) - *A*(2))^2 )

Taking the derivative of the expression on the right with respect to
*S*(1)

we have
*d* 1 2 (*S*(1) - *A*(1))
--------- = - --------------------------------------
*d* *S*(1) 2 ____________________________________
\/ (*S*(1) - *A*(1))^2 + (*S*(2) - *A*(2))^2 )

cancelling the factors of `2`

and noting that the denominator is equal to *r*1

you obtain
*d* *S*(1) - *A*(1)
--------- = ----------
*d* *S*(1) *r*1

which is the first element of the two element row vector *dr*1

defined by the assignment statement above.
A similar line of reasoning can be used to verify that second element of
*dr*1

and both elements of *dr*2

are the derivatives claimed above.
```
```

# derivative of range model with respect

# to the state vector xk (note derivative

# with respect to speed is zero)

dhk = {[dr1, 0, 0], [dr2, 0, 0]}

This statement sets *dhk*

to the derivative of *hk*

with respect to the State vector *xk*

.
Note that the derivatives with respect to the velocity components are all zero.
```
```

# variance of measurement noise

Rk = diag({2d0, 2d0}^2)

This statement sets *Rk*

to a double-precision diagonal matrix with two `2`

along the diagonal.
```
```

end

This statement terminates the `meas`

function definition.