For Loop Problem in Mathematica

  1. May 19, 2009 #1
    Hello,
    I want to execute a multiline code for each value of the for loop. How can I do that?
    Regards
     
  2. jcsd
  3. May 21, 2009 #2

    Dale

    Staff: Mentor

    For[
    i = 0, i < n, i++,
    line1;
    line2;
    line3
    ]
     
  4. May 21, 2009 #3
    Thanks DaleSpam. I used ',' instead of ';', which was not accepted by Mathematica. This saves a lot of effort.
    Best regards
     
  5. May 21, 2009 #4

    Dale

    Staff: Mentor

    No problem. You can always use ; to make a compound statement, so it is a general trick that helps elsewhere too.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Similar Discussions: For Loop Problem in Mathematica
  1. Mathematica looping (Replies: 3)

Loading...