Problem with for loop in user defined function

Hi All,

I have written a code whose core is reported below. The problem is that when I run the last two indented for loop, in the resulting "summation" waves (running over the j index) I find only zero values (the syntax seems fine, I don't have a warning message when I run the function). I had already this problem when I was trying to have everything in the same "big" for loop (the first reported below). To try to fix the problem, I splitted up the code in two different for loop, as reported below, but still I have problems. I have no idea how to solve it, if somebody could help me it would be great....and really appreciated!

Many thanks in advance!

Duncan
(a desperate postdoc :-) )


for (j = 0; j
It's not clear how you want this sum to work. Are you summing all waves into one value or are your summing each wave into a separate row in wout ... or something else?
jtigor wrote: It's not clear how you want this sum to work. Are you summing all waves into one value or are your summing each wave into a separate row in wout ... or something else?


So, I would like to sum the all i-waves generated during the first loop, so to sum together the "N1s" waves with different i index but different j index. Doing this, after the second loop I would like to have a number of "summation" waves equal to "lambda_points", each one obtained by the summation of all the "N1s" waves bearing the same j index (but of course different i).

I hope in this way it will be more clear....many many thanks for the help,

Duncan
Hi All,

I found the bug: I was treating my "N1s" waves as a variable (
Variable x3 = p
) and not as a wave. I have deleted the code line corresponding to the x3 specification and now it works!

Duncan