## Systems and Control Theory Lecture Notes

### Laura Giarr´ e

### Lab Session 3: Kalman

### The evolution of a cattle breeding can be described by a population dynamic model in input-state-output

### representation, in which a state variable represents the number of individuals in the corresponding class.

### We consider a model with the following classes:

*x* 1 *: young females; x* 4 : young males *x* 2 *: adult females; x* 5 : adult males *x* 3 *: old females; x* 6 : old males

### *If x* _{i} *(k) represents the number of heads in the i-th class*

_{i}

*during the year k, the population evolution is described by the*

*equations x(k + 1) = Ax(k) + u(k) + w(k)*

### with

*A =*

### ⎡

### ⎢ ⎢

### ⎢ ⎢

### ⎢ ⎢

### ⎣

*a* _{1} *a* _{2} *a* _{3} 0 0 0

*b* _{1} 0 0 0 0 0

### 0 *b* _{2} *b* _{3} 0 0 0 *c* _{1} *c* _{2} *c* _{3} 0 0 0

### 0 0 0 *d* _{1} 0 0

### 0 0 0 0 *d* _{2} *d* _{3}

### ⎤

### ⎥ ⎥

### ⎥ ⎥

### ⎥ ⎥

### ⎦

### *the coeﬃcients a* _{i} *and c* _{i} , i = 1, 2, 3, are the birthrates of female and male heads, respectively, from cows belonging to *the class x* _{i} ;

_{i}

_{i}

_{i}

### *the coeﬃcients b* _{i} *and d* _{i} , i = 1, 2, 3, are the surviving rates *of female heads of the class x* _{i} and of male heads of the class *x* _{i} + 3, respectively;

_{i}

_{i}

_{i}

_{i}

### *u* _{i} *(k) is the buying and selling balance of heads in the i-th* *class, during the year k;*

_{i}

### *w* _{i} *(k) represents the discrepancy between the true evolution of*

_{i}

*the i-th class and the nominal one predicted by the model.*

### Assume that we have data from an annual census of the cattle breeding, reporting the total number of female and male

### heads over a period of 101 years

*y* _{1} *(k) = x* _{1} *(k) + x* _{2} *(k) + x* _{3} *(k) + v* _{1} *(k)* *y* _{2} *(k) = x* 4 *(k) + x* 5 *(k) + x* 6 *(k) + v* 2 *(k)* *(k = 0, 1, ..., 100)*

### *where the variables v* _{j} *(k), j = 1, 2, represent the errors made*

_{j}

### in the census.

### Exercise A

### *Assume that w* _{i} *(k), i = 1, . . . , 6 and v* *j* *(k), j = 1, 2, can be* modeled as realizations of discrete-time stochastic white

_{i}

### processes, independent with each other, with zero mean and such that

### *the variance of processes w* _{i} *(k) is equal to σ* _{w} ^{2} ;

_{i}

_{w}

### *the variance of processes v* _{j} *(k) is equal to σ* _{v} ^{2}

_{j}

_{v}

### Design and implement a Kalman ﬁlter providing an estimate of the population in each class, by using the input data u(t) and the measurements y(t).

### Plot the obtained estimates and compare them with the true evolution of each class.

### Compute the state estimation error

*x(k)ˆx(k)* ^{2} and

### compare it with the corresponding expected value provided by the Kalman ﬁlter (the square root of the trace of the

### covariance matrix P.)

### Exercise B

### By using the Matlab function dlqe, design and implement the asymptotic Kalman ﬁlter relative to the same problem of

### exercise A.

### Compare the estimates provided by the asymptotic Kalman ﬁlter to those of the time-varying Kalman ﬁlter used in

### exercise A.

### Discuss the role of the Kalman ﬁlter initialization.

### Exercise C

### Consider the same evolution of the state variables as in

### exercise A (with the same input signal u(t)), but assume that a diﬀerent set of measurements y(t) is available. The

### measurement errors aﬀecting these new data have a standard deviation equal to *σ* _{v}

_{v}

_{j}*(k) = 3000.95* ^{k} ; j = 1, 2.

^{k}

### Apply the Kalman ﬁlter again, using these new measurements.

### Compare the estimates with those provided by a Kalman ﬁlter assuming a constant standard deviation for the measurement noise, equal to 300.

### Evaluate the estimation errors at each time instant in both

### cases, and compare them to the expected values provided by

### Exercise D

### Assume now that a new input-output data set is available, relative to the same model as in exercise A, but with a

*time-varying parameter a* _{2} such that *a* _{2} *(k) = 0.45 + 0.3 sin(2πk/20).*

### Apply the Kalman ﬁlter and compare the results to those obtained by using the ﬁlter adopted in exercise A (in which matrix A is constant).

### Evaluate the true state estimation errors of both ﬁlters and

### compare them to the expected values provided by the ﬁlters.

### DATA

### Data contained in lab3.mat refer to the following variables:

### parameters of the model:

*a* _{1} *, a* _{2} *, a* _{3} *, b* _{1} *, b* _{2} *, b* _{3} *, c* _{1} *, c* _{2} *, c* _{3} *, d* _{1} *, d* _{2} *, d* _{3} ;

### process variances *σ* _{w} ^{2} and *σ* _{v} ^{2} : sw2 and sv2, respectively;

_{w}

_{v}