Multiple WAVE references

Hello everyone,

this is the first time I'm using this forum asking an own question. Up to now I've found all answers allready in this forum. So thanks to all for this great community.

My actual problem is the following. I've created some folder which contains all the same waves with the same names:

Folder Ldut=1p        Waves: WWTime, V(vdut), I(L1)

Folder Ldut=1n        Waves: WWTime, V(vdut), I(L1)

Folder Ldut=10n        Waves: WWTime, V(vdut), I(L1)

Now I've created am Function to plot this waves. Therefor I need a reference to all waves in the actual folder. I'd like to select the folder and plot the corresponding graph.

Function GraphPlot()

    String strWaveList
    Variable iWaveNum
    Variable iCounter

    strWaveList = WaveList("*",";","")
    iWaveNum = ItemsInList(strWaveList)
   
    For(iCounter = 0; iCounter < iWaveNum; iCounter += 1)
        WAVE $(StringFromList(iCounter,strWaveList)
    EndFor 

    Display /K=1 /W=(336.75,90.5,1137,560) 'V(vdut)' vs WWTime
    AppendToGraph 'V(vdut+l)' vs WWTime
    AppendToGraph 'V(vnetz)' vs WWTime

My Problem is how to do the referencing of all waves in the folder.

The way I tried it in the for-loop does not work.

Can someone give me a hint how to do it?

Thanks in advance.

Jan

 

Hi Jan,

my first advice is to switch to functions as these are nicer to work with, more powerful and better debuggable.

Something like

Make/WAVE/N=(iWaveNum) waves = $StringFromList(p, strWaveList)

creates a wave reference wave which holds all the waves from the folder. You can then work with these.

Hej Thomas,

thanks for your quick reply. I've tried you idea and get the code running.

Function GraphPlot()

    String strWaveList
    Variable iWaveNum
    Variable iCounter

    strWaveList = WaveList("*",";","")
    iWaveNum = ItemsInList(strWaveList)
// 
//  For(iCounter = 0; iCounter < iWaveNum; iCounter += 1)
//      WAVE $(StringFromList(iCounter,strWaveList)
//  EndFor 
   
    Make/WAVE/N=(iWaveNum) waves = $StringFromList(p, strWaveList)
   
    Display /K=1 /W=(336.75,90.5,1137,560) waves[1] vs waves[0]
    AppendToGraph waves[2] vs waves[0]
    AppendToGraph waves[3] vs waves[0]
    AppendToGraph/R waves[4] vs waves[0]

I'm still wondering if it is possible to use the original wave-names instead of waves[n]. I mean a reference to every wave in a folder with its original name.

Maybe someone has an idea to that.

Thanks Jan

 

Hi Jan,

One idea is to use dim labels and use the string list to label the wave reference wave.  That way you can use either index or dim labels with the [%name] format.

Andy

>Therefor I need a reference to all waves in the actual folder.

Here are two ways to reference all the waves in the current data folder.

Function Demo1()
    Make/O jack, bob, fred
   
    Variable numWaves = CountObjectsDFR(:, 1)   // Number of waves in the current data folder
    Variable i
    for(i=0; i<numWaves; i+=1)
        Wave w = WaveRefIndexed("", i, 4)
        Print i, NameOfWave(w)
    endfor
End

Function Demo2()
    Make/O jack, bob, fred
   
    String list = WaveList("*", ";", "")
   
    Variable numWaves = ItemsInList(list)   // Number of waves in the current data folder
    Variable i
    for(i=0; i<numWaves; i+=1)
        String name = StringFromList(i, list)
        Wave w = $name
        Print i, NameOfWave(w)
    endfor
End

 

> I mean a reference to every wave in a folder with its original name.

Do you know the wave names at compile time?

If yes you can do something like

Function Dostuff()

    SetDataFolder someFolder
    Wave abcd
End

where a wave abcd is expected to be in someFolder.