Starting the vector with a certain value and the value starts at zero visually on the graph

3 views (last 30 days)
I am writing an unscented kalman filter code to estimate many parameters. It does not start the graph with the value corresponding to the initial vector. I start the vector x (:, 1) = [118562500 25 * 10e6 3 * 10e6 44000000 22000000] ', but when plotting the graphs, apparently all are plotted correctly and only the last position (22000000) starts at zero, which in theory in the chart should be at 22000000. But when looking at the table of interactions the value starts at 22000000. I am putting the code and graphics. I looked in some places and found nothing to help. I'm grateful for any information that might resolve this error.
x(:,1) = [118562500 25*10e6 3*10e6 44000000 22000000]';
Q = [15 0 0 0 0;
0 33 0 0 0;
0 0 45 0 0;
0 0 0 35 0;
0 0 0 0 20];
R = [.9 0 0;
0 .4 0 ;
0 0 .6];
P(:,:,1) = 1000e6*eye(5);
n = 5;
m = 3;
steps=38;
fXis = zeros(n, 2*n+1);
hXis = zeros(m, 2*n+1);
x(:,1) = x;
P(:,:,1) = P;
Pxz(:,:,2*n+1) = zeros(n, m);
for s = 2:steps
[Xis, W] = SigmaPoints(x(:,s-1),P(:,:,s-1),0);
for k = 1:2*n+1
fXis(:, k) = f(Xis(:,k));
end
[xp, Pp] = UT(fXis, W, Q);
for k = 1:2*n+1
hXis(:, k) = h(Xis(:,k));
end
[zp, Pz] = UT(hXis, W, R);
Pxz(:,:,s)=0;
for k = 1:2*n+1
Pxz(:,:,s) = Pxz(:,:,s)+ W(k)*((fXis(:,k) - xp)*(hXis(:,k) - zp)');
end
K(:,:,s) = Pxz(:,:,s)/Pz;
x(:,s)= xp + K(:,:,s)*(y(s,:)' - zp);
P(:,:,s)= Pp - K(:,:,s)*Pz*K(:,:,s)';
end
figure(1)
plot(x(1,:))
hold on
plot(y(:,1),'*')
title({'Population'},'FontSize',19,'FontName', 'Times New Roman')
legend({'Population Estimate','Population real'},'FontSize',19,'FontName', 'Times New Roman')
ylabel({'População'},'FontSize',19,'FontName', 'Times New Roman')
xlabel({'period (annual)'},'FontSize',19,'FontName', 'Times New Roman')
xticklabels({'1979','1984','1989','1994','1999','2004','2009','2014','2018'})
set(gca,'FontSize',19,'FontName', 'Times New Roman')
figure(2)
plot(x(2,:)/10e5)
hold on
plot(y(:,2)/10e5,'*')
title({'Population'},'FontSize',19,'FontName', 'Times New Roman')
legend({'Population Estimate','Population real'},'FontSize',19,'FontName', 'Times New Roman')
ylabel({'População'},'FontSize',19,'FontName', 'Times New Roman')
xlabel({'period (annual)'},'FontSize',19,'FontName', 'Times New Roman')
xticklabels({'1979','1984','1989','1994','1999','2004','2009','2014','2018'})
set(gca,'FontSize',19,'FontName', 'Times New Roman')
figure(3)
plot(x(3,:)/10e5)
hold on
plot(y(:,3)/10e5,'*')
title({'Population'},'FontSize',19,'FontName', 'Times New Roman')
legend({'Population Estimate','Population real'},'FontSize',19,'FontName', 'Times New Roman')
ylabel({'População'},'FontSize',19,'FontName', 'Times New Roman')
xlabel({'period (annual)'},'FontSize',19,'FontName', 'Times New Roman')
xticklabels({'1979','1984','1989','1994','1999','2004','2009','2014','2018'})
set(gca,'FontSize',19,'FontName', 'Times New Roman')
figure(4)
plot(x(4,:),'bo-')
title({'Population'},'FontSize',19,'FontName', 'Times New Roman')
legend({'Population Estimate','Population real'},'FontSize',19,'FontName', 'Times New Roman')
ylabel({'População'},'FontSize',19,'FontName', 'Times New Roman')
xlabel({'period (annual)'},'FontSize',19,'FontName', 'Times New Roman')
xticklabels({'1979','1984','1989','1994','1999','2004','2009','2014','2018'})
set(gca,'FontSize',19,'FontName', 'Times New Roman')
figure(5)
plot(x(5,:),'bo-')
title({'Population'},'FontSize',19,'FontName', 'Times New Roman')
legend({'Population Estimate','Population real'},'FontSize',19,'FontName', 'Times New Roman')
ylabel({'População'},'FontSize',19,'FontName', 'Times New Roman')
xlabel({'period (annual)'},'FontSize',19,'FontName', 'Times New Roman')
xticklabels({'1979','1984','1989','1994','1999','2004','2009','2014','2018'})
set(gca,'FontSize',19,'FontName', 'Times New Roman')
It also follows the table with the interactions carried out by the code that I am trying to plot
118562500 121212499,997614 123742542,150341 126426346,082141 129118273,542478 131832778,692062 134510635,840120 137128118,715222 139682271,260665 142179367,941344 144603822,773961 146954847,125511 149244949,048047 151442273,613485 153620579,867234 155727396,795777 157775276,081204 159560585,918667 161685733,853671 165881446,320792 169399657,284574 172249679,960785 174538687,332285 176760079,884540 181365154,964673 184075176,284862 186669791,437601 184168512,045249 189349011,714508 191398120,881165 190831196,285973 192341348,478630 193907233,669921 200701620,850982 202710186,405596 204405962,491866 206043296,706179 208471245,295796
250000000 22000000,0912001 23976194,9922362 6211585,66687527 44541168,7893320 7442608,15838259 8979601,22738014 15914986,5134179 25878925,0497041 9196918,35013697 2081653,68313932 14843970,7855502 12030103,1974611 82160074,5376664 19743841,1469367 4181475,54421278 14867454,6234561 3135072,18941689 33630825,8741533 75496563,3471235 84885681,5701706 41514460,3977642 15306868,2968538 64407765,8964271 5694560,42767510 3022711,27619960 2002508,91545325 12861662,3707758 45600885,0923905 46976410,0902807 2522507,77809139 1996249,51324110 13431,8770942525 2953493,13663503 1011610,78744729 8894352,45877193 7011060,20409812 322234684,918677
30000000 1000000,01740000 2974025,97415233 38630,2294287868 16779685,3054536 1204965,55388184 1989673,13528239 1012855,06640803 11857285,7314718 6076081,48015818 1065934,25861747 6922921,20866737 4037966,42029740 62234130,1089020 13639512,1668540 2151187,99973565 2001963,81180475 26003,9166530126 19740553,6872439 46645921,4869563 45021379,2102984 19337997,0067161 9134282,35365039 41573100,4840400 2514023,08059356 32655,1590308887 424,164529597980 2961037,89712631 18791666,6469590 29854412,6699442 387785,060966037 992047,815176688 12885,9115970923 2961199,76529461 1025474,42412893 3961363,28005886 2025476,54806079 214207652,028432
44000000 43999999,9853966 43999986,4145006 43999971,2411026 44000031,9504417 43999972,9756435 43999976,0262118 43999990,1658720 44000010,3237476 43999954,2068266 43999939,1390858 43999968,9042525 43999937,5162434 44000103,4147636 43999905,6512607 43999835,0301813 43999869,1733563 43999833,1200906 43999934,5413903 44000047,7791651 44000075,9218918 43999938,6771067 43999794,3857527 44000023,2080229 43999742,4314689 43999706,2412691 43999680,1887878 43999790,0613141 43999897,9276610 43999890,0537319 43999700,9103680 43999693,4476197 43999676,7662066 43999696,3890313 43999676,4971208 43999721,2972855 43999706,1555757 44001655,7998759
22000000 21997538,8248530 -1056752313,75455 -8840873895,84863 2049036473,85298 -12436369019,7983 -13743820683,8033 -13157096460,5294 -11487506631,2622 -18949272375,7825 -22969054280,1016 -20009706969,0122 -22428995260,3086 517530436,869549 -22791527798,8216 -29419071164,3254 -26827661506,1333 -31789755015,3480 -22447438783,2896 -10932964463,4889 -10176994502,7023 -27193928062,7840 -37521000196,7470 -21659905106,5100 -44863076220,9712 -47020063348,1316 -48464592255,0875 -42000149662,7759 -34167316104,8540 -34585868073,2011 -48313413210,6219 -48698189559,7777 -49573053728,4679 -52486900059,2376 -53556469341,4040 -51218525774,6794 -51998958736,9018 46276124736,9212
plotar.png

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!