farfair 发表于 2006-8-30 10:18

菜鸟请教卡尔曼滤波在matlab里的程序实现

因为毕业设计里边牵扯倒利用卡尔曼滤波法实现一定的检测,所以我很需要关于这方面的程序,不管是哪种语言的都可以,matlab语言编的那更是感激不禁了。很希望能与各位高手交流一下,请大家不吝赐教!

[ 本帖最后由 lxq 于 2006-10-13 15:51 编辑 ]

mathfish 发表于 2006-9-8 14:49

我有不过我不知道如何上传文件

flylele 发表于 2006-10-13 15:05

clear;clc;
A = [1.1269   -0.4940    0.1129
   1.0000         0         0
          0    1.0000         0];
B = [-0.3832
      0.5919
      0.5191];
C = ;
Plant = ss(A,,C,0,-1,'inputname',{'u' 'w'},'outputname','y');
Q = 1; R = 1;
= kalman(Plant,Q,R);

a = A;
b = ;
c = ;
d = ;
P = ss(a,b,c,d,-1,'inputname',{'u' 'w' 'v'},'outputname',{'y' 'yv'});
sys = parallel(P,kalmf,1,1,[],[])
% Close loop around input #4 and output #2
SimModel = feedback(sys,1,4,2,1)
% Delete yv from I/O list
SimModel = SimModel(,)

t = ';
u = sin(t/5);

n = length(t)
randn('seed',0)
w = sqrt(Q)*randn(n,1);
v = sqrt(R)*randn(n,1);

= lsim(SimModel,);

y = out(:,1);   % true response
ye = out(:,2);% filtered response
yv = y + v;   % measured response

subplot(211), plot(t,y,'--',t,ye,'-'),
xlabel('No. of samples'), ylabel('Output')
title('Kalman filter response')
subplot(212), plot(t,y-yv,'-.',t,y-ye,'-'),
xlabel('No. of samples'), ylabel('Error')

MeasErr = y-yv;
MeasErrCov = sum(MeasErr.*MeasErr)/length(MeasErr);
EstErr = y-ye;
EstErrCov = sum(EstErr.*EstErr)/length(EstErr);

sjh2100 发表于 2012-6-9 08:19

= lsim(SimModel,);

这语句如何理解参数作用,如果u为采集的输入信号,w,v各是什么意思?
页: [1]
查看完整版本: 菜鸟请教卡尔曼滤波在matlab里的程序实现