資源簡介
基于卡爾曼方法的預測短時交通流量的程序實現-To achieve based on the the short-time traffic flow of the the the forecast of the Kalman method procedures

代碼片段和文件信息
clear?all;
close?all;
N=60;???????????????????????????????%采樣周期
a=load(‘speed.txt‘);%讀取速度數據
X(1)=60;
v=randn(1N);???????????????????????%模型噪聲
w=randn(1N)*5;?????????????????????%觀測噪聲
X_est(1)=60;
X_est_1(1)=60;
P(1)=1;
for?k=1:N
????Y(k)=a(k);
????if?k>1
????????X(k)=X(k-1)+v(k-1);??????????%狀態方程
????????Y(k)=X(k)+w(k);?????????????%測量方程
????????P_1(k)=P(k-1)+cov(v);
????????K(k)=P_1(k)/(P_1(k)+cov(w));%卡爾曼增益
????????X_est_1(k)=X_est(k-1);
????????X_est(k)=X_est_1(k)+K(k)*(Y(k)-X_est_1(k));
????????P(k)=(1-K(k))*P_1(k);
????end
????rerr(k)=(X_est_1(k)-X(k))/X(k);
????rerr_1(k)=(X_est(k)-X(k))/X(k);
end
figure(1)
plot(X_est_1‘r‘);hold?on
plot(X‘b‘);hold?on
plot(Y‘g‘);
axis([0?N?10?100]);
legend(‘預測值‘‘真實值‘‘測量值‘);
figure(2)
plot(rerr);
legend(‘預測相對誤差‘);
figure(3)
plot(X_est‘r‘);hold?on
plot(X‘b‘);hold?on
plot(Y‘g‘);
axis([0?N?10?100]);
legend(‘估計值‘‘真實值‘‘測量值‘);
figure(4)
plot(rerr_1);
legend(‘估計相對誤差‘);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1027??2012-07-28?15:25??基于卡爾曼方法的預測短時交通流量的程序實現\kalman.m
?????文件????????361??2012-07-28?15:27??基于卡爾曼方法的預測短時交通流量的程序實現\speed.txt
?????目錄??????????0??2015-07-11?11:24??基于卡爾曼方法的預測短時交通流量的程序實現
-----------?---------??----------?-----??----
?????????????????1388????????????????????3
評論
共有 條評論