|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
是这样的,我用S函数编写了一个扩展卡尔曼滤波辨识电机转动惯量的程序,辨识结果收敛时间大概在7-8s的样子,但是看到国内外很多论文上大概的收敛时间在1s以内,个人感觉问题所在已在参考程序中注明,但是没有想到解决方法,所以希望知道的朋友能够帮忙解决一下,先谢谢了!
参考程序:function [ sys, x0, str, ts ] = EKFLITER(t, x, u, flag)
%This S - Function is to indentify the inertia online using extended kalman
%filter method.
%x(1) = w(estimate speed)
%x(2) = TL(load torque)
%x(3) = 1/J(J is inertia of motor)
%u(1) = Te
%u(2) = w(the real speed)
switch flag,
case 0,
[ sys, x0, str, ts ] = mdlInitializeSizes;
case 2,
sys = mdlUpdate(t, x, u);
case 3,
sys = mdlOutputs(t, x, u);
case {1, 4, 9},
sys = [ ];
otherwise
error([ 'Unhandled flag = ', num2str(flag) ]);
end
function [ sys, x0, str, ts ] = mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 3;
sizes.NumOutputs = 2;
sizes.NumInputs = 2;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [ 0 0 1500 ];
str = [ ];
ts = 1e-4;
function sys = mdlUpdate(t, x, u)
ts = 1e-4;
A = [ 1 - x(3)*ts 0; 0 1 0; 0 0 1 ];
B = [ x(3)*ts 0 0 ]';
P = diag([ 1 1 10 ]); %*
C = [ 1 0 0 ];
H = [ 1 0 0 ];
Q = diag([ 1e-5 1e-4 5e-6 ]);
R = 5e-3;
y = u(2);
Y = C*x;
G = [ 1 - x(3)*ts u(1) - x(2)*ts; 0 1 0; 0 0 1 ];
%The first step
x = A*x + B*u(1);
P = G*P*G' + Q; %*
% P = G*P*G' + Q;%这里应该是用P = G*Pe*G’ + Q但是由于Pe在之前没有定义所以不能用, 现在的问题在于, 本来是一个迭代循环, 可是现在P每次更新都被重置为diag[ 1 1 10 ], 所以程序的收敛速度非常慢。看看哪位朋友能帮忙解决一下, 就是起始的P值为diag[ 1 1 10 ], 之后P = G*Pe*G’ + Q, 多谢大家了, 已经弄了好几天了, 没有找到方法。
% %The second step
K = P*H'/(H*P*H' + R);
Xe = x + K*( y - Y );
Pe = P - K*H*P;
%Result
sys(1) = Xe(1);
sys(2) = Xe(2);
sys(3) = Xe(3);
function sys = mdlOutputs(t, Xe, u)
%Output sys(1) is load torque
%sys(2) is inertia J
sys(1) = Xe(2);
sys(2) = 1/Xe(3);
|
|