# Trying to access element of a matrix [duplicate]

Possible Duplicate:

I'm trying to extract element of a matrix. Let's suppose that the matrix is

ACC = {{1, 0, 0, 1}, {0, 0, 0, 2}, {0, 0, 0, 3}, {0, 0, 0, 1}}


then

ACC[[1,4]]


will return 3. I don't understand why Mathematica is giving me the error Part::partw when trying to get the value [[1,x]] with x>1 of the following matrix Rbar: (sorry for the code but it wont work otherwise)

Avz[\[Theta]z_,
dz_] := {{Cos[\[Theta]z], -Sin[\[Theta]z], 0, 0}, {Sin[\[Theta]z],
Cos[\[Theta]z], 0, 0}, {0, 0, 1, dz}, {0, 0, 0, 1}};

Avx[\[Theta]x_,
dx_] := {{1, 0, 0, dx}, {0, Cos[\[Theta]x], -Sin[\[Theta]x],
0}, {0, Sin[\[Theta]x], Cos[\[Theta]x], 0}, {0, 0, 0, 1}};

Linea[tz_, dz_, tx_, dx_] := Avz[tz, dz].Avx[tx, dx];

Grid[{{"", "Theta", "d", "Alpha", "a"}, {"Link1",
InputField[Dynamic[t1], FieldSize -> 3],
InputField[Dynamic[d1], FieldSize -> 2],
InputField[Dynamic[alpha1], FieldSize -> 4],
InputField[Dynamic[x1], FieldSize -> 1]}},
Frame -> Darker[Gray, .6], Alignment -> {{Left, {Center}}}]

Rt = {{1, 0, 0, -L1/2}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};

Rbar = Dynamic[Linea[t1, d1, alpha1, x1].Rt]


here Rbar[[1,4]] for example returns error, but why?

• hi @narutov6, don't forget that MMA is case sensitive. You use ACC and Acc. It's a good practice to use all user function as lower case to avoid conflict. – Murta Jan 23 '13 at 1:23
• With your matrix ACC[[1,3]] is 0, not 3. – Szabolcs Jan 23 '13 at 1:23
• The reason why Rbar[[1,4]] does work the way you expect is because of the incorrect use of Dynamic in Rbar. – Szabolcs Jan 23 '13 at 1:25
• – rm -rf Jan 23 '13 at 1:25
• Jens's answer on your earlier question should solve this one too: "The Dynamic should wrap the expresion you want to display" – Szabolcs Jan 23 '13 at 1:42