Possible Duplicate:
Question about MapThread and Dynamic
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?
ACCandAcc. It's a good practice to use all user function as lower case to avoid conflict. – Murta Jan 23 '13 at 01:23ACC[[1,3]]is0, not3. – Szabolcs Jan 23 '13 at 01:23Rbar[[1,4]]does work the way you expect is because of the incorrect use ofDynamicinRbar. – Szabolcs Jan 23 '13 at 01:25Dynamicin a similar incorrect way. I was just trying to find it, but no luck so far. – Szabolcs Jan 23 '13 at 01:27Dynamicand not extracting what you expect then try wrapping your expression inFullFormto see what you are actually operating on. – Mike Honeychurch Jan 23 '13 at 02:43d=Dynamic[Rbar[[1,4]]];` Thanks
– UserK Jan 23 '13 at 14:26