I'm relatively new to using Kalman filters. To get my feet wet, I'm
working on a program simulating a sounding rocket with a barometric
pressure sensor to determine apogee. I've taken "ideal" altitude data
and overlaid white noise to approximate a noisy pressure sensor. I've
been able to "guess" (hardcode) gain values that allow the filter to
track the data relatively closely, however I'm having trouble
determining the correct gains (to minimize the error covariance)..

Based on the white noise I've used, the barometric pressure sensor noise has a stdev#.65 meters. I'm ballparking that the process noise only occurs in acceleration (wind, buffeting, etc), and has a stdev of 10 m/s^2. Therefore, the Q and R matricies that I'm using are:

Q=[0 0 0 0 0 0 0 0 100]

R=[559.5 0 0 0 0 0 0 0 0]

However, when the program encounters the code to calculate the new gains K, I get the following: "Warning: Matrix is singular to working precision".

Can anyone spot a mistake I'm making in determining Q or R? Below is the "meat" of the filter I'm using, in case that is the source of the errors. (note: I'm defining P as a 3 X 3 X "time interval" matrix)

Thanks in advance for any help or advice! Dave

--------------------------------------------------- while i<=off x1=A

P1=(A

i=i+1; XK(i,1)=X(1); XK(i,2)=X(2); XK(i,3)=X(3); end

Based on the white noise I've used, the barometric pressure sensor noise has a stdev#.65 meters. I'm ballparking that the process noise only occurs in acceleration (wind, buffeting, etc), and has a stdev of 10 m/s^2. Therefore, the Q and R matricies that I'm using are:

Q=[0 0 0 0 0 0 0 0 100]

R=[559.5 0 0 0 0 0 0 0 0]

However, when the program encounters the code to calculate the new gains K, I get the following: "Warning: Matrix is singular to working precision".

Can anyone spot a mistake I'm making in determining Q or R? Below is the "meat" of the filter I'm using, in case that is the source of the errors. (note: I'm defining P as a 3 X 3 X "time interval" matrix)

Thanks in advance for any help or advice! Dave

--------------------------------------------------- while i<=off x1=A

***X; X=x1+K***(y_meas(i)-x1(1));P1=(A

***P(:,:,i))***A'+Q; K=P1***H'***inv(H***P1***H'+R) P(:,:,i+1)=(I-K1***H)***P1;i=i+1; XK(i,1)=X(1); XK(i,2)=X(2); XK(i,3)=X(3); end