1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Nested for and lists in mathematica

  1. Sep 29, 2012 #1
    Hello, I'm new using Mathematica and actually can't understand what's the problem in this code

    Code (Text):

    l = {}

    For[k = 1, k < 3,
     For[j = 1, j < 3,
        t1 = RandomInteger[{1, 10}];
        t2 = RandomInteger[{1, 10}];
        t = (t1 + t2)/2;
        j++;
        ]
       l = Append[l, t];
     k++;
     ]
     
    The error I get is

    Set::write: Tag Times in Null {} is Protected. >>

    I've also tried to use an array or a table in the place of the list l, but the error persist.
    It's like if after the nested for, I couldn't append elements to the list or add elements to an array.

    Have you any idea to do what I would like to do?
     
    Last edited by a moderator: Sep 29, 2012
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Nested for and lists in mathematica
  1. Mathematica Hw (Replies: 0)

  2. Mathematica plot (Replies: 0)

Loading...