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. >>


1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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