New Reply

Printing results if certain conditions are met in Mathematica

 
Share Thread
Jun11-12, 04:51 PM   #1
 

Printing results if certain conditions are met in Mathematica


Hello everyone,

I have for loop in Mathematica. After every step Mathematica has new results calculated. I want to see only some results, those who met certain conditions, not results from all steps. Say, I have 10000 steps and I don't need all 10000 results, but only those that met certain conditions. There are at least two or more conditions to be met. How can I tell Mathematica to print only those results?

So I want to tell this to Mathematic ain a for loop:

If a is true and b is true or c is true and d is true, then print blablabla, else do nothing.
PhysOrg.com science news on PhysOrg.com

>> City-life changes blackbird personalities, study shows
>> Origins of 'The Hoff' crab revealed (w/ Video)
>> Older males make better fathers: Mature male beetles work harder, care less about female infidelity
Jun12-12, 01:15 PM   #2
 
In[1]:=For[i=1,i<100,i++,
(*doing stuff*)
If[Or[And[i>25,i<30],And[Mod[i,7]==3,Mod[i,11]==8]],Print[i]]
(*doing more stuff*)
]

From In[1]:=26
From In[1]:=27
From In[1]:=28
From In[1]:=29
From In[1]:=52
Jun12-12, 05:08 PM   #3
 
Thank you very much for your kind replay :).
New Reply

Similar discussions for: Printing results if certain conditions are met in Mathematica
Thread Forum Replies
Fortran: printing the Printing the Hex contents of a character variable Programming & Comp Sci 1
If and Mod conditions together in mathematica Math & Science Software 0
Mathematica: NDSolve with InterpolatingFunction as initial conditions Math & Science Software 14
Different Values, Constanst Results in Mathematica Math & Science Software 6
What's the difference between initial conditions and boundary conditions? Differential Equations 9