Kn = 0.05;	/* measurement noise variance */


N=21;		/* number of data points */

dt = 4/(N-1);       /* time will go from 0 to 4 */
t = [0:N-1]*dt;

x = [0:(N-1)]/5;

noise = sqrt(Kn)*rand(1,N,"gauss");

z = x + noise;

xv = ones(1,N);		/* x velocity */


/* initialize kalman stuff */

T = dt;

A = [ 1 T; 0 1];
C = [ 1 0];

Ke = eye(2,2);

S2a = 0.1;	/* S2a*T is noise acceleration spectral height */
Kn = 0.05;	/* measurement noise variance */

Ku = [ T*T*T*T/3  T*T*T/2;  T*T*T/2  T*T] * S2a;


xhat = zeros(2,N);

xhat(1,1) = x(1);
xhat(2,1) = xv(1);
