There is a matrix (4*4) m as below one:


I do not write all of elements. The r[i,j] is created by a table and after a calculation its elements have appeared in the m. But in any elements of m, I want to see the difference between j and i. For example 256-1=255 for the first step. It must be repeated to all others which are adding to that. If for a special r, j-i is not equal to the others, I can see that r. I mean If I have


I must be notified that r[10,267] is wrong. Because it must be r[10,265].

Since There are many elements contribute to m I am not able to do that by hand. How can I gain this goal?


Let's make some fake data to play with:

data = Table[r[n + m, 255 + n + m], {n, 1, 20}, {m, {0, 10}}];

Then let's introduce an error:

data = data /. r[3, 258] -> r[3, 1000];

We can then conditionally format the r items that do not correspond to your rule:

data /. r[i_, j_] /; i + 255 != j :> Style[r[i, j], Red, Bold, Background -> Yellow]

Mathematica graphics

As you can see, the offending item is visually highlighted in the output.

  • $\begingroup$ I am grateful to receive again one of your perfects answers as before. $\endgroup$ – Unbelievable Jun 8 '17 at 10:10
  • $\begingroup$ @Irreversible that's very kind, you are welcome! $\endgroup$ – MarcoB Jun 8 '17 at 13:36

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.