I’m kinda new to using Mathematica, so any help is appreciated.
Is it possible in Mathematica to use multiple iterators in for loops? Something like
For[i=1, j=1, i<1, j<3, i++, j++, ]
and so on? I’m getting an error on this, is there a different way to write this sort of syntax in Mathematica? Thanks!
You can try something like this:
For[(i = 1; j = 1),
i < 3 && j < 3,
(i++; j++)]
I.e., use compound espressions and the And operator (the &&). (Note that I changed your i<1 to i<3 so something would actually happen.) But, as many in this group will suggest, you really should take some time to learn about the different programming approaches in Mathematica so that you move away from the procedural approach of using things like For and Do loops.
You can get a taste here:
[Wolfram Video Archive: Elementary Programming in Mathematica
a](Wolfram Video Archive: Elementary Programming in Mathematica)nd begin to get launched into learning things here:
http://reference.wolfram.com/mathematica/guide/CoreLanguageOverview.html
What is it that you want to archive? For loops can usually (and should) be avoided, since there are better constructs.
In your example, it looks like i and j always have the same value, so one of them is redunant. If this is not the intention, but you want all pairs of combinations,
then you can use Do:
Do[
code
,{i,1,3},{j,1,2}];