⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 verification.m

📁 Source code in Matlab to simulate a kalman filter s functioning.
💻 M
字号:
clear all;
%close all;

Q1=1;
R1=1;

%tv=5;
%t=1:1:35;
%tv=5*t;
%tv=50*sin(2*pi*100*t);
tv=[-79.1 -79.1 -79 -78.8 -78.6 -78.3 -77.9 -77.9 -77.7 -77.8 -77.9 -77.9 -77.8 -77.4 -77 -77.3 -76.8 -76.6 -76.3 -75.8 -75.3 -75.1 -74.7 -75.1 -75.3 -75 -74.9 -74.5 -74.1 -73.9 -72.8 -73.5 -73.1 -73 -72.7] ;

%randn('seed',0);
%w = sqrt(Q1)*randn(35,1);
%pv=tv+w;
%v = sqrt(R1)*randn(35,1);
%mv=pv+v;

s=randint(1,1,[2,10]);
gn=wgn(1,35,0,1,s);   pv=tv+gn;   
s=randint(1,1,[2,25]);
gn2=wgn(1,35,0,1,s);    mv=pv+gn2;

%pv=tv+(-Q1+(2*Q1).*rand(size(tv)));     
%mv=pv+(-R1+(2*R1).*rand(size(tv)));      

Q=20;
R=20;
pe(1)=25;

i=0;
tve(1)=0;
k(1)=0;
tvp(1)=0;


    tve(1)=-70;
    pc(1)=pe(1)+Q;
    k(1)=pe(1)/(pe(1)+R);
    tvp(1)=tve(1)+k(1)*(mv(1)-tve(1));
    
for i=2:1:35,
    tve(i)=tvp(i-1);
    pe(i)=pc(i-1)+Q;
    k(i)=pe(i)/(pe(i)+R);
    tvp(i)=tve(i)+k(i)*(mv(i)-tve(i));
    pc(i)=(1-k(i))*pe(i);
end

t=1:1:35;
%subplot(1,1,1);
%scatter(t,mv);
%plot(t,tv,t,mv,t,tvp);
%legend('True Values','Measured Values','Estimated Values',0)
%title({'Blue=TV, Green=MV, Red=TVP';['TV range is |5|, errors range is |1|',' Q is ',num2str(Q),' R is ',num2str(R),' Pe is ',num2str(pe(1))]});
%subplot(2,1,2)
%plot(t,tv-tvp,t,mv-tvp);
%legend('True Values-True values predicted','Measured Values-True values predicted',0)
%subplot(1,1,1)
%plot(tvp);

figure(2)
grid on;
subplot(1,1,1);
h=plot(t,tv,t,mv,t,tvp);
set(h,'LineWidth',2,'MarkerSize',8,{'LineStyle'}, {'-';'X';'--'})
set(h,{'Color'},{'b';'g';'r'});
legend('True Values','Measured Values','Estimated Values',0);
xlabel('Time');
ylabel('Simulated Voltage');
title({'TV={set of 35 values from lab(100W bulb,no lens)';['Q1=',num2str(Q1),' R1=',num2str(R1)];'gn=wgn(1,35,0,1,s);   pv=tv+gn;';'gn2=wgn(1,35,0,1,s);    mv=pv+gn2;';[' Q is ',num2str(Q),' R is ',num2str(R),' Pe is ',num2str(pe(1))]});
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -