Do something for all waves in a graph

Dear all,

I have a bunch of waves plotted in a graph (but the waves are situated in distinct data folders). The idea is that I would like to apply a function on all the waves in the plot and not care where they are in the folders.

Is there a way to do that in Igor?

T
Could you be more specific about "apply a function"? Are you doing a math operation or are you doing a curve-fit?

Generally, you can work on all waves on a graph by using the TraceNameList operation. This will return the name of every wave on the current graph (you can restrict this to omit hidden waves if you wish). Then, you can use TraceNametoWaveRef in order to link the trace name (a string) to the actual wave. Finally, if you have x-waves, use the XWaveRefFromTrace operation to get the wave reference for the x-wave.

Run a for loop for then number of names in the tracelist to do your operations.

string list = tracenamelist("",";", 1)   //get list of normal traces on topmost graph

variable i
for (i=0; i<itemsinlist(list); i+=1)
   wave ywave = TraceNametoWaveRef("", stringfromlist(i, list, ";"))   //trace i from top most graph
   wave xwave = XwaveRefFromTrace("", stringfromlist(i, list, ";"))     //x wave associated with trace i

   // insert code here to do your desired operation (curve fitting, fft, basic math, derivative, area, etc.)
endfor
Hi

I was trying to integrate all the curves in the graph, no matter where they are in the data browser. The resulting wave has to keep the number of the original wave (to be able to distinguish) in between in the root folder. I am using now the above code with the integration:

Integrate/METH=1 ywave/X=xwave/D=R_int;DelayUpdate

But I think the R_int will be re-writen after the first curve got integrated. I do not know but the result is just a wave called R_int. how can I keep the original name of the wave?

Thanks for support!

T

If I understand you correctly, you want the destination wave to be named based on the wave from your graph and the result to be stored in the root folder.

One danger here is the event of 2 waves of similar name in different folders (the resultant integrated waves would have the same name and therefore can't be kept in the root folder together).

String yname = NameofWave(ywave)   //get the name of the y wave
String dest_wave = yname + "_int"      //  add  _int to name to distinguish from source

Integrate/METH=1 ywave/X=xwave/D=$Dest_Wave;DelayUpdate    //use string Dest_Wave to name the destination wave based on the y-wave name.