Assignment has more non-singleton rhs dimensions than non-singleton subscripts in UKF
1 view (last 30 days)
Show older comments
I'm trying to apply the unscented kalman filter as elaborated in the Artigo , to perform the estimation of the lambdah parameter of a time series. When implementing the code I get the following error
The commands in line 62 are hXi (:, k) = h (fXi (:, k)); and the error message i
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in Parametro_UKF (line 62) hXi(:,k) = h(fXi(:,k)); %h(Xi)
Hence I do not know how to do it because my measurement function only has three inputs of the five, that is, I only have the series of three variables. How to proceed, I'm trying to calculate the prediction of the measure through function h and Sigma Fxi points. I know there has to be dimensions, but I can not fathom how to correct.
It follows the implanted codes for the accomplishment of the parameter estimation.
I appreciate any help! If you notice any more errors please let me know, I do not know how to program very well!
6 Comments
Walter Roberson
on 19 Sep 2018
Out of those 18 values, which 3 would you like to store in hXi(:,k) ?
Accepted Answer
Walter Roberson
on 19 Sep 2018
hXi = zeros(18, 2*n+1);
for k = 1:2*n+1
hXi(:,k) = reshape( h(fXi(:,k)), [], 1); %h(Xi)
end
3 Comments
Walter Roberson
on 19 Sep 2018
Well, you can do things like
hXi = cell(1, 2*n+1);
zp = cell(1, 2*n+1);
Pz = cell(1, 2*n+1);
for k = 1:2*n+1
hXi{k} = h(fXi(:,k)); %h(Xi)
[zp{k}, Pz{k}] = UT(hXi{k}, W, R);
end
Pxz = zeros(n, m);
for k = 1:2*n+1
Pxz = Pxz + W(k)*(fXi(:,k) - xp)*(hXi{k} - zp{k})';
end
but it will not work in the Pxz calculation.
(fXi(:,k) - xp) will be 6 x 1
hXi{k} will be 3 x 6. zp{k} will be 3 x 1. Since R2016b it has been legal to take 3 x 6 minus 3 x 1, which would be treated like bsxfun(@minus, 3x6, 3x1) which would give a 3 x 6 result. Then the conjugate transpose of that is taken, giving a 6 x 3 result.
And now you are stuck, since you cannot use * between a 6 x 1 and a 6 x 3.
You appear to be expecting a 6 x 3 result. The only way to get that out of a * with a 6 x 3 is if the first expression were to give a 6 x 6.
You need to trace out exactly what size you are expecting from each result.
More Answers (0)
See Also
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!