Jojo
Jojo

Reputation: 1117

Error: Index exceeds matrix dimensions in long equation

I've been stuck on this error for quite a while and think I'm missing something simple. The error is in the code below (which I haven't shown as code as it will all appear as one line and I thought this may be easier to view). I am very sorry for the length of the equation, the simplify function in MATLAB did not help to reduce the size much. All the matrices are of size 1 x 300 and W and Y are scalars. However, I seem to get the Error: Index exceeds matrix dimensions.

X1n = (A12(1,:).^2.*A1S13(1,:).*W + A13(1,:).^2.*A1S12(1,:).*Y -  ...
       A12(1,:).*A13(1,:).*A1S12(1,:).*W - A11(1,:).*A22(1,:).*A1S13(1,:).*W + ...
       A11(1,:).*A23(1,:).*A1S12(1,:).*W - A12(1,:).*A23(1,:).*A1S11(1,:).*W + ...
       A13(1,:)*A22(1,:).*A1S11(1,:).*W - A12(1,:).*A13(1,:).*A1S13(1,:).*Y + ...
       A11(1,:).*A23(1,:).*A1S13(1,:).*Y - A13(1,:).*A23(1,:).*A1S11(1,:).*Y - ...
       A11(1,:).*A33(1,:).*A1S12(1,:).*Y + A12(1,:).*A33(1,:).*A1S11(1,:).*Y + ...
       A23(1,:).^2.*A1S11(1,:).*W.*Y - A12(1,:).*A23(1,:).*A1S13(1,:).*W.*Y + ...
       A13(1,:).*A22(1,:).*A1S13(1,:).*W.*Y - ...
       A13(1,:).*A23(1,:).*A1S12(1,:).*W.*Y + ...
       A12(1,:).*A33(1,:).*A1S12(1,:).*W.*Y - ...
       A22(1,:).*A33(1,:).*A1S11(1,:).*W.*Y)./(Y.*(A33(1,:).*A12(1,:).^2 - ...
       2*A12(1,:).*A13(1,:).*A23(1,:) + ...
       A22(1,:).*A13(1,:).^2 + A11(1,:).*A23(1,:).^2 - ...
       A11(1,:).*A22(1,:).*A33(1,:)))

Upvotes: 0

Views: 52

Answers (1)

R. Schifini
R. Schifini

Reputation: 9313

Here is your error (line 4):

A13(1,:)*A22(1,:)

Change it to:

A13(1,:).*A22(1,:)

Upvotes: 1

Related Questions