Physics Forums

Physics Forums (http://www.physicsforums.com/index.php)
-   Math & Science Software (http://www.physicsforums.com/forumdisplay.php?f=189)
-   -   For Loop Problem in Mathematica (http://www.physicsforums.com/showthread.php?t=315078)

S_David May19-09 12:39 PM

For Loop Problem in Mathematica
 
Hello,
I want to execute a multiline code for each value of the for loop. How can I do that?
Regards

DaleSpam May21-09 06:46 AM

Re: For Loop Problem in Mathematica
 
For[
i = 0, i < n, i++,
line1;
line2;
line3
]

S_David May21-09 09:46 AM

Re: For Loop Problem in Mathematica
 
Quote:

Quote by DaleSpam (Post 2207237)
For[
i = 0, i < n, i++,
line1;
line2;
line3
]

Thanks DaleSpam. I used ',' instead of ';', which was not accepted by Mathematica. This saves a lot of effort.
Best regards

DaleSpam May21-09 10:50 AM

Re: For Loop Problem in Mathematica
 
No problem. You can always use ; to make a compound statement, so it is a general trick that helps elsewhere too.


All times are GMT -5. The time now is 01:16 AM.

Powered by vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2014 Physics Forums