Re: For loop outputs to a list
- To: mathgroup at smc.vnet.net
- Subject: [mg112879] Re: For loop outputs to a list
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Tue, 5 Oct 2010 05:31:11 -0400 (EDT)
- References: <i8c90m$gd8$1@smc.vnet.net>
- Reply-to: nma at 12000.org
On 10/4/2010 3:07 AM, matthew wrote: > For[i = 0, i< 10^6, i++, > If[Abs[Re[LS2[0.004 + i*Pre]] - Re[RS[0.004 + i*Pre]]]< 10^-7 , > Print[N[0.004 + i*Pre]] > If[0.004 + i*Pre> 0.007, Break[]] > ]]; I can't read your code above, it seems missing something? after the Print[..] you have If[...], nothing in between? Any way, assuming you trying to do For[i = 0, i < 10^6, i++, If[..., result =. .., result =. ...] ] Then you can try using a Table? result = Table[{i, If[ ..., x , y ]}, {i, 0, 10^6-1}}] If[] will have side effect the result that got computed as its value, i.e. weither x or y. do not use Print[x], just leave x as is. This will give a table with the first column having the value 'i' and the second column having the result found for that i. hth --Nasser