Reputation: 49
I am trying to evaluate the following expression:
(-a(3)*(4*b(1,1)*b(2,2)-b(1,2)*b(2,1))+b(3,2)*(2*b(1,1)*a(2)+b(1,2)*b(2,1)))/(2*b(3,3)*(4*b(1,1)*b(2,2)-b(1,2)*b(2,l,1))-b(3,2)(2*b(1,1)*b(2,3)-b(1,2)*b(2,1)))
It is for expression (in latex):
$\left(\frac{-a_3 (4\beta_{11}\beta_{22}-\beta_{12}\beta_{21} ) +\beta_{32}(2\beta_{11}a_2+\beta_{12}\beta_{21})}
{2\beta_{33} (4\beta_{11}\beta_{22}-\beta_{12}\beta_{21} ) -\beta_{32}(2\beta_{11}\beta_{23} - \beta_{12}\beta_{21})}\right)$
Matlab keeps complaining that:
Error: ()-indexing must appear last in an index expression.
I want to check if I have the simplification right and would need such expression to be evaluated.
Upvotes: 2
Views: 1583
Reputation: 9864
You have to add an asterisk after b(3,2)
. Currently the term that starts with b(3,2)
is like this:
b(3,2)(2*b(1,1)*b(2,3)-b(1,2)*b(2,1))
You should change it to
b(3,2)*(2*b(1,1)*b(2,3)-b(1,2)*b(2,1))
The problem is that Matlab interprets that as indexing b(3,2)
which is already an indexed expression.
Upvotes: 3
Reputation: 283624
It looks like your matrix b
is two-dimensional, but your expression contains b(2,l,1)
which has three subscripts.
The original formula didn't have any l
in it.
Upvotes: 2