




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、function ParticleEx1% Particle filter example, adapted from Gordon, Salmond, and Smith paper.x = 0.1; % initial stateQ = 1; % process noise covarianceR = 1; % measurement noise covariancetf = 50; % simulation lengthN = 100; % number of particles in the particle filterxhat = x;P = 2;xhatPart = x;% In
2、itialize the particle filter.for i = 1 : Nxpart(i = x + sqrt(P * randn;endjArr = 0;xArr = x;yArr = x2 / 20 + sqrt(R * randn;xhatArr = x;PArr = P;xhatPartArr = xhatPart;close all;for k = 1 : tf% System simulationx = 0.5 * x + 25 * x / (1 + x2 + 8 * cos(1.2*(k-1 + sqrt(Q * randn;%狀態(tài)方程y = x2 / 20 + sqr
3、t(R * randn;%觀測方程% Extended Kalman filterF = 0.5 + 25 * (1 - xhat2 / (1 + xhat22;P = F * P * F + Q;H = xhat / 10;K = P * H * (H * P * H + R(-1;xhat = 0.5 * xhat + 25 * xhat / (1 + xhat2 + 8 * cos(1.2*(k-1;%預(yù)測xhat = xhat + K * (y - xhat2 / 20;%更新P = (1 - K * H * P;% Particle filterfor i = 1 : Nxpartm
4、inus(i = 0.5 * xpart(i + 25 * xpart(i / (1 + xpart(i2 + 8 * cos(1.2*(k-1 + sqrt(Q * randn;ypart = xpartminus(i2 / 20;vhat = y - ypart;%觀測和預(yù)測的差q(i = (1 / sqrt(R / sqrt(2*pi * exp(-vhat2 / 2 / R;end% Normalize the likelihood of each a priori estimate.qsum = sum(q;for i = 1 : Nq(i = q(i / qsum;%歸一化權(quán)重en
5、d% Resample.重采樣for i = 1 : Nu = rand; % uniform random number between 0 and 1qtempsum = 0;for j = 1 : Nqtempsum = qtempsum + q(j;if qtempsum = uxpart(i = xpartminus(j;if k = 20qArr=q;jArr = jArr j;endbreak;endendend% The particle filter estimate is the mean of the particles.xhatPart = mean(xpart;% P
6、lot the estimated pdfs at a specific time.if k = 20% Particle filter pdfpdf = zeros(81,1;for m = -40 : 40for i = 1 : Nif (m = xpart(i & (xpart(i m+1pdf(m+41 = pdf(m+41 + 1;endendendfigure;m = -40 : 40;plot(m, pdf / N, r;hold;title(Estimated pdf at k=20;disp(min, max xpart(i at k = 20: , num2str(min(
7、xpart, , , num2str(max(xpart;% Kalman filter pdfend% Save data in arrays for later plottingxArr = xArr x;yArr = yArr y;xhatArr = xhatArr xhat;PArr = PArr P;xhatPartArr = xhatPartArr xhatPart;endt = 0 : tf;%figure;%plot(t, xArr;%ylabel(true state;figure;plot(t, xArr, b., t, xhatArr, g-., t, xhatArr-2
8、*sqrt(PArr, r:, t, xhatArr+2*sqrt(PArr, r:; axis(0 tf -40 40;set(gca,FontSize,12; set(gcf,Color,White;xlabel(time step; ylabel(state;legend(True state, EKF estimate, 95% confidence region;grid on;figure;plot(t, xArr, b., t, xhatPartArr, k-;set(gca,FontSize,12; set(gcf,Color,White;xlabel(time step; ylabel(state;legend(True state, Particle filter estimate;grid on;xhatRMS = sqrt(norm(xArr - xhatArr2 / tf;xhatPartRMS = sqrt(norm(xArr - xhatPartArr2 / tf;disp(Kalman filter RMS error = , num2str(xhatRMS;disp(Particle filter RMS error = , num2str(xhatPartRMS;/*qArrtt=max(qArrt=jArrm,n=hi
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 工匠評比活動方案
- 局二人三足比賽活動方案
- 小小科學(xué)家活動活動方案
- 常州公園活動方案
- 小學(xué)踢毽活動方案
- 居民公共活動方案
- 少先隊鄉(xiāng)下活動方案
- 干部講壇活動方案
- 小班踏春活動方案
- 居雅裝飾公司優(yōu)惠活動方案
- 《急性胰腺炎診治》課件
- 變壓器知識點(diǎn)培訓(xùn)課件
- 《《資本論》第一卷導(dǎo)讀》課件
- 池州八中英才班數(shù)學(xué)試卷
- 老年照護(hù)培訓(xùn)課件
- 幕墻工程項目演練
- 大學(xué)英語(B)(1) 江蘇開放大學(xué)考試資料
- 中資企業(yè)在哈薩克斯坦發(fā)展報告(2023-2024)【簡本】
- 新媒體運(yùn)營說課CHAPTER課件講解
- 物業(yè)燃?xì)獍踩嘤?xùn)課件
- 老年護(hù)理實踐指南手冊(試行)全匯編
評論
0/150
提交評論