Index exceeds matrix dimensions,

3 vues (au cours des 30 derniers jours)
Baity Jannaty
Baity Jannaty le 25 Sep 2019
Commenté : Baity Jannaty le 25 Sep 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.

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Sep 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 ?
  1 commentaire
Baity Jannaty
Baity Jannaty le 25 Sep 2019
Thank you very much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by