Use Wavelist to programmatically declare and use waves
Hi--
The goal of this function is average one second data to some other value, say one minute. I want to use Wavelist or some other method, to determine the wave names in the selected folder, and then average them, plot them, etc.. The problem I'm currently having is I cant get the function to compile because the call for declaration is incorrect. Once I figure out how to be able to work with the waves that Wavelist has identified as being in the directory I can move on. For instance let's say I want to next graph ListoWaves[0] vs Timewave then I can move on. See inserted code. As usual thanks in advance for any help.
ssmith
String ListoWaves = Wavelist("*",";","DP:1") //"DP:1" selects only dbl precision float waves to be averaged, eliminates text waves String Timewave = Wavelist("*time*",";","DP:1") //Identifies the time wave // Print ListoWaves // Print Timewave Variable NumWaves = ItemsinList(ListoWaves) //finds the number of items in wavelist // Print Numwaves Wave/T WL = ListToTextWave(Listowaves,";") FOR(e=0;e<(NumWaves);e+=1) Wave WaveDeclare = $WL[e] ENDFOR
If I put your code in a function, the compiler complains that your variable e is not declared. If I add this before the for loop, it then compiles:
Note that I would suggest not using "e" as the name of a variable since it's also the name of a built-in function and that could be confusing, but it's allowed.
October 29, 2025 at 02:29 pm - Permalink
Note that since Igor 9 you can also do a range-based loop, which would get rid of the variable e and would collapse the latter half of your code into a convenient expression:
Also note that with your current method of creating the lists, Timewave is contained within ListoWaves. Maybe you want that, but if not you either want to use:
String ListoWaves = Wavelist("!*time*",";","DP:1")or run RemoveFromList() later.
October 29, 2025 at 07:08 pm - Permalink