How to index index in the third dimension?

2 views (last 30 days)
GTA
GTA on 23 Nov 2018
To debug the code in a simpler way it would also be good if I saved all the information as tensors, that is, putting the index "s" in the third dimension and leaving the others free. With this, I want to see all the sigma points, estimated variances, etc. How could you carry out this process? The following is part of the code where I want to apply this indexing.
x(:,1) = [208701300 326*10e6 217*10e6 44000000 22000000 lambdah]';
P(:,:,1) = 1e6*eye(6);
n = 6;
m = 3;
steps=38;
fXis = zeros(n, 2*n+1);
hXis = zeros(m, 2*n+1);
x_pred(:,1) = x;
P_pred(:,:,1) = P;
Pxz(:,:,2*n+1) = zeros(n, m);
for s=2:steps
[Xis, W] = SigmaPoints(x_pred(:,s-1),P_pred(:,:,s-1),1);
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(:,:,s)] = 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(:,:,s);
x_pred(:,:,s)= xp + K(:,:,s)*(y_total(s,:)' - zp);
P_pred(:,:,s)= Pp - K(:,:,s)*Pz(:,:,s)*K(:,:,s)';
end
Many thanks for any help!

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!