I am quite new to IGOR, so any help is appreciated. I feel this is quite a simple general question. I have 50 waves and would like to automate applying a procedure to each of these waves (i.e. in a table). The waves are named in increments i.e. in the format wave_% where % goes from 0 to 50.
How would I construct some sort of loop to apply to the waves? This would save me applying the function in the procedure to all 50 waves manually in the command window!
You're likely to get a more helpful response if you give more details about exactly what you are trying to do. "Applying a procedure to each of these waves" doesn't really make sense, so I'm not sure what you want to do.
If you want to do the same thing to sequentially named waves that are all within the same data folder (if you haven't learned about data folders yet, they probably are), you can use code like this below:
Function ProcessWaves(prefixString, firstNum, lastNum) String prefixString // The part of the name that is common to all waves. Variable firstNum // Number of the first wave in the series. Variable lastNum // Number of the last wave in the series.
Variable n String currentWaveName For(n=firstNum; n<=lastNum; n+=1) sprintf currentWaveName, "%s%d", prefixString, n
WAVE currentWave = $(currentWaveName)
// Below is where you would add the code you want to process // the current wave. The code below is just an example of what // you might do.
printsum(currentWave)// Prints the sum of all points in the wave to the command line.
// Add your code above here. EndFor End
To use this function, you might execute the following command from the Igor command line:
ProcessWaves("wave_", 0, 50)
NOTE: You mentioned something about a table. I didn't know what you meant, so ignored that part. Were you trying to do the same thing to many waves, all of which are displayed in a table?
If you want to do the same thing to sequentially named waves that are all within the same data folder (if you haven't learned about data folders yet, they probably are), you can use code like this below:
String prefixString // The part of the name that is common to all waves.
Variable firstNum // Number of the first wave in the series.
Variable lastNum // Number of the last wave in the series.
Variable n
String currentWaveName
For (n=firstNum; n<=lastNum; n+=1)
sprintf currentWaveName, "%s%d", prefixString, n
WAVE currentWave = $(currentWaveName)
// Below is where you would add the code you want to process
// the current wave. The code below is just an example of what
// you might do.
print sum(currentWave) // Prints the sum of all points in the wave to the command line.
// Add your code above here.
EndFor
End
To use this function, you might execute the following command from the Igor command line:
NOTE: You mentioned something about a table. I didn't know what you meant, so ignored that part. Were you trying to do the same thing to many waves, all of which are displayed in a table?
July 3, 2009 at 09:10 am - Permalink