Making Waves in for loops

My code snippet is given below.

This is the problem I've been stumped on:
Instead of having to use concatenate, I was wondering if there is any way I can make new "permanent" waves to save my results in. For example, how can I create a series of automatically named waves like (levels_0.1, levels_0.2), using the for loop, so that each time my loop is iterated, the results from FindLevels is copied into the series of appropriate waves. I would like that instead of saving the data to SelectiveCrossings and then using concatenate to override the overwriting in each iteration.

I'm sure it is something quite simple, and have been trying to look at example procedures but haven't been successful so far, any help would be greatly appreciated! I'm a beginner to Igor.

 
    Make/O/N=0 AllCrossings
    for(i=0; i<numPoints; i+=1)
        yvalue = rawwave1[i] //This basically contains all my data points/trace
        FindLevels /D=SelectiveCrossings/EDGE=0/R=(0,29)/N=30/Q rawwave1, yvalue
//This goes through each of the data point, and then basically finds out the places where that particular point is crossed through the series of data points.
        Concatenate /NP {SelectiveCrossings}, AllCrossings
//In order to accommodate for overwriting my destination wave in each iteration of the for loop, I just used concatenate. It takes all the resulting data for each iteration
//displaying them in one single wave, as a column/list.
        count0 += 1
    endfor    
<pre><code class="language-igor">
string theName
for (...)
   theName = "Crossings" + num2str(i)
   make/O/N=0 $theName
   wave destwave=$theName
   FindLevels /D=destwave ...
   ...
endfor


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
Thanks very much J.J. I was wondering as you frequently answer my questions on the forum, do you have any particular useful references that a beginner like me in Igor could use to read up on general things about the Igor programming Interface?
One more question [quote] J.J. Weimer

I used the code snippet that you sent me and it works great. Thank you very much.

But now that I have divided the data accordingly, if I wanted to make a for loop where I can access each wave separately and run their elements through the same calculation, would I use something like LoadWave in my for loop?

Like this is the rough calculation I must try on each element of the Crossings0, Crossings1, Crossings2 waves:

 
      for(j=0; j<numPoints3; j+=1)
       //for each value in AllCrossings we will evaluate the hitting function
            if(rawwave3[j]>rawwave4[j])
               if(rawwave5[j]<crossing0)
                   Yvalueundercrossing[count1] = rawwave5[j]
                   Xvalueundercrossing[count1] = rawwave3[j]
                   count1 += 1
               endif
            print Yvalueundercrossing
            print Xvalueundercrossing
         count3 += 1
     endfor
igorman wrote:

But now that I have divided the data accordingly, if I wanted to make a for loop where I can access each wave separately and run their elements through the same calculation, would I use something like LoadWave in my for loop?


I'm not J.J. but anyway ;-)

If the waves you want to access reside within the experiment (e.g. they are visible in the data browser) you don't need LoadWave. This is to load waves from disc into an experiment. You'll need to create a wave reference within your function. To read more about this, execute:

DisplayHelpTopic "Accessing Global Variables And Waves"
DisplayHelptopic "Converting a String into a Reference Using $"


and for general reading I'd recommend the manual chapter IV-3 "User defined functions".

If you have a list of waves with common names and consecutive numbers you can use the following technique to access each of those waves individually:

function AccessCrossings()
   
    String List = WaveList("crossing*", ";", "")            // Make a string list with all waves starting with "crossing"
    variable i
   
    for (i=0; i<ItemsInList(List); i+=1)
       
        String NextString = StringFromList(i, List)
        wave NextWave = $NextString               // this creates a local reference to an existing wave
         
        print NameOfWave(NextWave)                     // do something with NextWave
       
    endfor
end



ChrLie wrote:
igorman wrote:

But now that I have ... ?


I'm not J.J. but anyway ;-)



Thanks for the stand in my place. Your comments are always appreciated in the forum.

To igorman ... I offer the same recommendations as ChrLie made. You will do better to read the manual and try the programming examples it has. Otherwise, you will continue to build a bigger and bigger function with a cluttered array of small pieces that you only half understand, and you will later be fully confused when you inadvertently want to modify something in it.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville