During the execution of the following code a column of three lists and two sliders are displaying in output. The first list updates if either a or b changes. The second list updates only if the value of a is changed. Similarly, the third list updates only if the value of b is changed.
a = 0;
b = 0;
Column[
{
Dynamic[{a, b}, TrackedSymbols :> {a,b}],
Dynamic[{a, b}, TrackedSymbols :> {a}],
Dynamic[{a, b}, TrackedSymbols :> {b}],
Slider[Dynamic[a], {0, 1}],
Slider[Dynamic[b], {0, 1}]
}
]
Next I would like to replace {a,b} by a list x with two elements:
x = {0, 0};
Column[
{
Dynamic[{x[[1]], x[[2]]}, TrackedSymbols :> {x}],
Dynamic[{x[[1]], x[[2]]}, TrackedSymbols :> {x[[1]]}],
Dynamic[{x[[1]], x[[2]]}, TrackedSymbols :> {x[[2]]}],
Slider[Dynamic[x[[1]]], {0, 1}],
Slider[Dynamic[x[[2]]], {0, 1}]
}
]
It is easy to check that now only the first list updates. Please help me to solve this problem.
x[[1]]
is not aSymbol
. The dynamic updating system probably only tracks symbols, not parts of them, so probably you can't do it the second way. $\endgroup$TrackedSymbols
must be taken strictly; i.e., it accepts only symbols, not expressions. $\endgroup${a, b} = {0, 0}
in your first example, so I ask: why doesn't that work for you? $\endgroup$Dynamic[x[[1]], (x[[1]] = tester = #1) &]
...TrackedSymbols :> {tester}
$\endgroup$