# using FindRoot in for loop [closed]

I am fairly new to Mathematica so I am not really familiar with all the "kinks" in its syntax (a matlab lover). I am trying to run this:

del = 0.01;
L = 15;
Res = ConstantArray[0, {L, L}];
For [i = 1, i <= L, \[Alpha] = i*del,
For[j = 1, F <= L, F = j*del,
q = {\[CurlyEpsilon] -> 0.1, \[Lambda] -> 0.01, \[Omega] -> 1.2};
eqc1 = eqc /. q;
eqs1 = eqs /. q;
sol = FindRoot[{eqc1 == 0, eqs1 == 0}, {{A, 1.6}, {\[Psi], 0}}];
{A, \[Psi]} = {A, \[Psi]} /. sol;
Res[[i, j]] = A;
]
]


eqc and eqs are defined function with parameters listed in list "q", alpha and F. I am sloving for A and psi. outside of a loop, the FindRoot runs for less than a second. when I deifne L=1 (equivillent to a single calculation), the calculation stalls. I do know that for some values of alpha and F, the calculation errors out. What I would like to know is, how can I tell the program to ignore the error and just continue? or even better provide some sort of output into my matrix ("Res") saying that for this combination of parameters there is no solution.

I am sorry for any obvious "Noob" mistakes :)

Thank you very much to all of you!!!

-
That's some confusing loop, note that you never increment i or j. You might want to look at Table or Array pretty much the same as a For loop but creates a matrix with the results: Array[f, {3, 3}] Table[f[i, j], {i, 3}, {j, 3}] – ssch Feb 5 at 11:18
As inspiration in the Mathematica way of doing things, have a look at what happens when you evaluate Partition[0.1 {First@#, Last@#} & /@ Tuples[Range@15, 2],15] – image_doctor Feb 5 at 12:03
Since this has been closed, I'll just mention in comments that there are some serious problems with your code. First, as ssch mentioned, the iterators don't increment. Second, you can't use A and psi both as things to be solved for and things to have values assigned to them: you may not get the expected result after running the loop once. Third, how would i and j affect the equations if they did change? You can take the definition of q out of the loop at least. You should also check out this question. – Verbeia Feb 6 at 2:29

## closed as too localized by belisarius, Sjoerd C. de Vries, Oleksandr R., whuber, F'xFeb 5 at 13:40

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.