Index exceeds matrix dimensions,

3 visualizaciones (últimos 30 días)
Baity Jannaty
Baity Jannaty el 25 de Sept. de 2019
Comentada: Baity Jannaty el 25 de Sept. de 2019
When I run ukf_main, there is error messge:
Index exceeds matrix dimension. I really dont know where is my fault. Thank for all of your response.

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Sept. de 2019
xPred = sum(wSigmaPts_xmat .* (xPredSigmaPts(:,2:nsp) - repmat(xPredSigmaPts(:,1),1,nsp-1)),2);
xPredSigmaPts is a 6 x 1 double at the time of the error. You cannot take column 2 to nsp of a matrix that only has one column.
xPredSigmaPts = feval(ffun,xSigmaPts(1:states,:),repmat(U(:),1,nsp),xSigmaPts(states+1:states+vNoise,:),dt);
And ffun is ffun1, and ffun1 is
xout = [ 0.01919*x(6)^2 - 0.00051691*x(4)^2 + 0.96268*x(2)*x(4) - 0.013784*x(1)^2;
0.0012494*x(4)*x(2)^2 - 0.007995*x(6) - 0.031872*x(4) - 1.0196*x(4)*x(1) - 0.001264*x(4)*x(2) - 0.0046864*x(3) + 1.5585e-6*x(4)^3 - 0.0035837;
5.7303*x(6) - 2.9402*x(3) - 3.0606*x(4) + 1.961*x(4)*x(1) + 0.77732*x(4)*x(2) + 1.2159*x(4)*x(2)^2 + 0.00043617*x(4)^3 - 51.392;
0.0051138*x(3) + 0.025393*x(6) + 0.053875*x(4) + 0.0039023*x(4)*x(1) + 0.0023632*x(4)*x(2) - 0.0030146*x(4)*x(2)^2 - 1.9436e-6*x(4)^3 + 0.000013716;
x(4)*cos(x(6));
x(3)];
That uses the first 6 elements of x no matter how large it is, and returns a 6 x 1 vector. At the time of the error, what is being passed in is 6 x 17.
Perhaps you should be calling ffun1 once for each column ?

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by