Two indented loops
I have a problem during the developing of a function for Igor. A couple of weeks ago, I had a very useful tip from John Weeks, how to make a for loop in a user defined function. This function essentially creates a certain number of gaussian peaks defined through the variable "points", shifted by the values contained in the wave "BEs" and multiplied by the values contained in the wave "exp_dump". Now, I'm trying to edit this function introducing a higher level of complexity. As you can see below, I would like to create, with this new modified function, the same set of data but using several different waves for the "exp_dump", since every single "exp_dump" wave contains a different decay mode. In few words, I want to replicate the same calculation contained in the old function but using different waves for the "exp_dump". In principle, I could do this manually, but the problem is that the "exp_dump" waves are provided by the our experimental equipment, and the number of these waves are so high that I really need for a code......For sake of clarity, I have reported below both the old core and the new function that I'm trying to develop.
Many thanks for your support,
Duncan
//"OLD FUNCTION"
Function simulation(points,FWHM,V_index,theta)
variable points
variable FWHM
variable V_index
variable theta
variable i
string N1s_peak_
WAVE BEs
WAVE BE_scale
WAVE exp_dump
for (i = 0; i
Modify your new code like this:
Also note that you should avoid using "q" as loop index because it is a built in function in Igor.
April 24, 2015 at 12:23 pm - Permalink
Again, thanks a lot for your support! It was extremely helpful!
Duncan
April 24, 2015 at 10:58 am - Permalink
I'm back with a problem. Here is the code on which I'm working on:
So, in the second for loop within the primary one I want to make a summation of the waves previously generated by the first indented for loop (i.e. "N1s_peak_"). The function runs with no problems but, when I go to the results, in the "summation" waves (correctly indexed by j) I find that all the 161 values are zero. Where do I make a mistake? Could somebody help me?
Many thanks in advance for your help,
Duncan
April 24, 2015 at 04:12 pm - Permalink
Once that works, put it in a for-loop ...
Build your code this way. You can debug it a lot easier (and we can read it better to help you).
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
April 30, 2015 at 02:59 pm - Permalink
This is a really good tip! Thanks!
Duncan
May 4, 2015 at 11:10 am - Permalink