Search code examples
wolfram-mathematica

Why do i receive the error : Set::write: Tag Times in Null w is Protected


Hey guys this is my first time posting so I hope I do this right.

Im trying to run a bit of code in mathematica:

VtanList = {};

Do[


 For[j = 1, j <= Length[file], j++,

     test = {data[[i, j]]}[[1, 2]] - {data[[i, j + 1]]}[[1, 2]];
     If[test >= 0,
      peak = j + 5;
      j = Length[file] + 10;
      ]
     ]

    w = Take[data[[i]], {1, peak}];


     , {i, Length[file]/256}]

What the data List looks like:

data = {{1,2},{3,2},{1,6},{2,4}}

When I recieve the error:

Tag Times in Null w is Protected.

I've tried exiting the kernel, and it doesn't seem to be the classic A+B=C problem I have read about.

I could really use your help, Thanks!!!


Solution

  • Add a semicolumn after For[..]

    Without it, Mathematica thinks that For[..] and w = .. are parts of one continuous expression and, obviously, multiplying a for loop with an assignment operation does not make any sense.