
Help to make a function that operate on several waves

phil
Good morning,
I am still very new with Igor and I
am trying to generate a function that would allow me to operate on several waves in a table (wave0 to wave100 or more) without having to type each one of these operation.
The operation I am trying to do is newwave = (wave0 - mean(wave0 x1, x20))/ mean(wave0 x1,x20)
I would like the function to generate a tab that would have all the new waves.
Would appreciate any help and explanation you can provide.
Thank you
Hi Phil,
A couple things for your request. The first is to create a function to do the normalization and that is straight forward, but one thing to keep in mind is data organization which includes both the wave name of the new wave and also if there is a different data folder where you would like/need to segregate the new waves. For example if you have a different data folder for the normalized wave, then you can reuse the input wave name. This may be useful it keeping track of the resulting waves. In this example the new wave stays in the same directory as your current working folder which maybe different than the source input wave.
Now to run this function over a group of waves in a table takes a couple of steps and does depend on how things are named and placed in the first function. First figure out how waves are in the table and I am assuming that they are are all 1D waves. Then go through the table info column by column and extract the wave name and run it through the first function. I also need to keep track of the waves added using the same naming convention. This could be made more robust by having the first function return a string with the new wave name, but I wanted to keep things simple here. Lastly I create a blank table and then add the newly normalized waves to that table.
Hope this is a start.
Andy
December 27, 2020 at 05:44 pm - Permalink
Welcome to the forum. If you are now to Igor I very much recommend to read and do the Guided Tour in the Igor Manual. I know, most of the time one doesn't even take the manual out of its wrapping when getting into new software. However in the case of Igor the manual is not only excellent but will make a great difference to get good results fast. Otherwise Andy gave you a good start to tackle you problem. I can imagine that lots of this stuff may look like code salad to you. If you want to do things a little bit easier, maybe you can break up your problem into smaller pieces. For example, you may want to stop working with tables and organize your data in a way which makes it easier to write simple functions.
December 28, 2020 at 12:24 am - Permalink
In reply to Hi Phil, A couple things… by hegedus
thanks a lot!
December 30, 2020 at 11:02 am - Permalink