作业帮 > 综合 > 作业

请matlab高手解决kalman问题

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/04/28 19:51:13
请matlab高手解决kalman问题
A=[0.49,0.298,0.412;0.401,-0.391,0.391;-0.992,0.401,0.296];
B=zeros(3.3);
G=eye(3,3);
C=[0,1,0];
D=[0,0,0];
H=zeros(1,3);
X(:,1)=[10.9,8.481,-4.3]';
guji=[20.1,21.3,20.7]';
for i=2:30
W=randn(3,1);
V=randn(1,1);
X(:,i)=A*X(:,i-1);
X1(:,i)=X(:,i)+W;
On=eye(2,2);
Rn=1;
Nn=0;
Z0(:,i)=C*X1(:,i)+V;
sys=ss(A,[B,G],C,[D,H],-1);
[kest,L,P,M,Z]=kalman(sys,On,Rn,Nn);
guji(:,i)=A*guji(:,i-1)+L*A*guji(:,i-1);
end
subplot(2,2,1);
plot(x(1,:))
hold on
plot(guji(1,:),':m')
hold off
legend('real of X1','estimate of X1')
grid
subplot(2,2,2)
hold on
plot(guji(2,:),':m')
hold off
legend('real of X2','estimate of X2')
grid
subplot(2,2,3:4)
plot(X(3,:))
hold on
plot(guji(3,:),':m')
hold off
legend('real of X1','estimate of X1')
grid
Warning: Size vector should be a row vector with integer elements.
不胜感激!
请matlab高手解决kalman问题
A=[0.49,0.298,0.412;0.401,-0.391,0.391;-0.992,0.401,0.296];
B=zeros(3,3);G=eye(3,3);C=[0,1,0];D=[0,0,0];
H=zeros(1,3);X(:,1)=[10.9,8.481,-4.3]';
guji=zeros(3,30);
guji(:,1)=[20.1,21.3,20.7]';
for i=2:30
W=randn(3,1);
V=randn(1,1);
X(:,i)=A*X(:,i-1);
X1(:,i)=X(:,i)+W;
On=eye(2,2); Rn=1;
Nn=0;
Z0(:,i)=C*X1(:,i)+V;
sys=ss(A,[B,G],C,[D,H],-1);
[kest,L,P,M,Z]=kalman(sys,On,Rn,Nn);
guji(:,i)=A*guji(:,i-1)+L'*A*guji(:,i-1);
end
subplot(2,2,1);plot(X1(1,:))
hold on
plot(guji(1,:),':m')
hold off
legend('real of X1','estimate of X1')
grid
subplot(2,2,2)
hold on
plot(guji(2,:),':m')
hold off
legend('real of X2','estimate of X2')
grid
subplot(2,2,3:4)
plot(X(3,:))
hold on
plot(guji(3,:),':m')
hold off
legend('real of X1','estimate of X1')
grid
按上面语句试试
再问: 你运行了吗?我运行了一下,还是不行呀
再答: (在附件中另外附有可运行程序。)不好意思啊。我上面的程序第25句plot(x(1,:))改成plot(X(1,:)).也就是要大写X