Problem with Kalman Filter and state space model
显示 更早的评论
I'm currently designing a Kalman Filter to filter my noisy active power measurement data, which are dependent of the inputs frequency and voltage. Therefore i tried to recreate the system behaviour using transfer functions and i converted them into a space model with A,B and C using the Parameter Estimator App in SIMULINK. These matrices are used as follwing for my state space model:

A=[-55.6,0.0485;0.4125,-39.3134];
B=[7.3617,-0.0139,-1.5236,4.3344];
C=[7.3780,-11.0682];
If i compare the created state space model data with the measurement data, i get the following plot or results, which looks good:

blue is measurement data, orange is model data;
My Kalman Filter is based on the follwing work: http://bilgin.esme.org/BitsAndBytes/KalmanFilterforDummies
function [y_dachk,K_k,xk_1]=Kalman_Filtering(A,B,C,R,Q,z_k,Input_Voltage,Input_Frequency)
% Initialisation
I = eye(2);
Q_M = I.*Q;
xk_1=[0;0];
P_kmin1=[0.01,0;0,0.01];
for k = 1:length(Input_Voltage)
% Time Update (prediction)
%1. Project the state ahead
x_k = A*xk_1+B*[Input_Voltage(k);Input_Frequency(k)];
%1. prediction state
%P_k=A*P_kmin1*transpose(A)+Q_M;
% Correction Step
%1. Kalman Gain
K_k=P_k*transpose(C)*((C*P_k)*transpose(C)+R)^(-1);
%2. Update states
delta=z_k(k)-C*x_k;
xk_1 = x_k+K_k*delta;
%3. uptade covariance
P_kmin1=(I-K_k*C)*P_k;
y_dachk(k)=C*xk_1;
end
end
The problem i have at the moment is, it doesnt correct the noisy data, instead it recreates the measurement signal if i run the code above:

This means it's two times the same signal. This is the first thing what confuses me.
The second one is the fact, if i set the Kalman Gain K_k to zero, i would expect to always get the predicted state and therefore also the output of my state space model in the first graphic. But this is not the case. I can't plot it, because after a few steps the values of y_dach are NaN. I'm struggling to understand where my laplace integration takes place here, because if i interpret the equations of http://bilgin.esme.org/BitsAndBytes/KalmanFilterforDummies my x_k before the integration is my next xk_1 used by the measurement function. The integration just gets neglected.
I would be happy to get some help or advice on the aspect since i'm struggling to solve the problem. Thanks for your help.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 State-Space Control Design and Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!