Index exceeds matrix dimensions.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
why??
D = zeros(size(M,1),size(M,1),size(M,2));
for k=(size(M,2)-1):-1:1
P_pred = A(:,:,k) * P(:,:,k) * A(:,:,k)' + Q(:,:,k);
D(:,:,k) = P(:,:,k) * A(:,:,k)' / P_pred;
M(:,k) = M(:,k) + D(:,:,k) * (M(:,k+1) - A(:,:,k) * M(:,k));
P(:,:,k) = P(:,:,k) + D(:,:,k) * (P(:,:,k+1) - P_pred) * D(:,:,k)';
end
the error is for line P_pred = A(:,:,k) * P(:,:,k) * A(:,:,k)' + Q(:,:,k);
0 Kommentare
Antworten (1)
Stephen23
am 17 Sep. 2017
Bearbeitet: Stephen23
am 17 Sep. 2017
Because you are trying to access some part of an array that does not exist. Just like this:
>> A = rand(4,3,2);
>> A(:,:,99)
??? Index exceeds matrix dimensions.
>>
My example array only has size 2 along the third dimension, so what do you expect to happen if I try to access the 99th position along the third dimension?
If you really want to learn how to write and debug your own code then one very important skill is to start actually looking at your code. You could have very easily figured this error out yourself by looking at each of the variables, and trying each part of that line: break it down into atomic operations, and trying them in the command line. And by reading the error message of course.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!