Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please, tell me what is the issue with the following code?

Dimensions[Subscript[R, 2]]
{201, 161, 53}
  If[Subscript[R, 2][[x, y, z]] != 2, Subscript[R, 2 ][[x, y, z]] = 0], 
  {x, 1, 201}, {y, 1, 161}, {z, 1, 53}];

I am getting this error:

Set::setps: Subscript[R, 2] in the part assignment is not a symbol. >>

share|improve this question
Related: – halirutan Nov 3 '13 at 3:35

What you see here is the direct result of ignoring advice:

Don't use subscripted variables if you don't know the concequences!

What happens is that you think you assign your array to a variable R... you don't! Basic example

Subscript[a, 1] = {1, 2, 3}

(* {1, 2, 3} *)

Now try ?a and if this doesn't work, try to find where your list is stored. Right, it is stored as DownValues for Subscript:


(* {HoldPattern[Subscript[a, 1]] :> {1, 2, 3}} *)

Unfortunately, the assignment operator for list elements aka

l[[n]] = blub

does not work here. Therefore, use simple symbols and you are fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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