Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

Dimensions[Subscript[R, 2]]
{201, 161, 53}
Table[
  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: mathematica.stackexchange.com/q/869/187 –  halirutan Nov 3 '13 at 3:35

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:

DownValues[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

 
discard

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.