there is some 20 Time 20 tables, in each step we choose one element randomly. how can show this random selected element with different color?

  • $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Nov 13 '15 at 10:13
  • 2
    $\begingroup$ Take a look at the answers to this question as well: Identifying locations of entries in an array. $\endgroup$ – MarcoB Nov 13 '15 at 15:46

We define a function f with the style of for the TextCell

Do[f[i, j] = Black, {i, 10}, {j, 10}]

We display the table as a Dynamicentity

  Table[TextCell[Subsuperscript[X, i, j], f[i, j]], {i, 10}, {j, 10}]]

Mathematica graphics

Now every time you do a random selection, you can change the style of that specific cell, which will be updated in a Dynamic way. As an example, every second a random item with a random colour.

 f[RandomInteger[10], RandomInteger[10]] = 
  Sequence @@ {Bold, RandomChoice[{Red, Blue, Green}],   Background -> Yellow}
 , 100]

enter image description here

  • $\begingroup$ how you saved the dynamic table as a ".gif" ? $\endgroup$ – jack cilba Nov 21 '15 at 1:45

For better presentation I've decreased size of matrices to 4.

n = 4;
MatrixForm[m = Array[Subscript[a, ##] &, {n, n}]]

enter image description here

With[{ij = {RandomInteger[{1, n}], RandomInteger[{1, n}]}},
  ReplacePart[m, ij -> Style[m[[Sequence @@ ij]], Red]]
  ] // MatrixForm

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.