How to take averages and standard deviation of specific sections of a wave

I am trying to create a code that is able to take averages and standard deviation of specific sections of a wave. There are multiples sections that I want to take averages of. I also want to be able to put the averages and standard deviations I calculate into a new table. I am unsure of where to start and how to code this. Any help would be appreciated!
Hi,

If the section of the wave is contiguous then the problem is very simple.
mean(waveName [, x1, x2 ] )
The mean function returns the arithmetic mean of the wave for points from x=x1 to x=x2.
Variance(inWave [ , x1, x2 ] )
Returns the variance of the real-valued inWave . The function ignores NaN and INF values in inWave .

The variance is std dev^2.

If the section is not contiguous then you first need to create the wave with the points you want. The exact method will depend on the details of problem at hand.

For example if you wanted to take the data in chucks of 10, you might start with a for loop and in this simple example I will assume you base data has 100 points

Function MakeSummary()
 
   wave ydw = yourdatawave //reference
   make/O /N=(10,2) summarywave //I usually include overwrite because I run things over and over and don't want to create new ones all the time

  // optional but I like to label my dimensions and then use labels so I don't need to track exact indices
   setdimlabel 1,0,Mean,Summarywave
   setdimlabel 1,1,sd,Summarywave

  variable index // i usually use "index" since the template insertion uses that and I don't have rename

   for(index=0;index<10;index+=1)
     summarywave[index][%mean] = mean(ydw,index*10,index*10+9)
     summarywave[index][%sd]     = sqrt(variance(ydw,index*10,index*10+9))
   endfor
End






Andy
hegedus wrote:
Hi,

If the section of the wave is contiguous then the problem is very simple.
mean(waveName [, x1, x2 ] )
The mean function returns the arithmetic mean of the wave for points from x=x1 to x=x2.
Variance(inWave [ , x1, x2 ] )
Returns the variance of the real-valued inWave . The function ignores NaN and INF values in inWave .

The variance is std dev^2.

If the section is not contiguous then you first need to create the wave with the points you want. The exact method will depend on the details of problem at hand.

For example if you wanted to take the data in chucks of 10, you might start with a for loop and in this simple example I will assume you base data has 100 points

Function MakeSummary()
 
   wave ydw = yourdatawave //reference
   make/O /N=(10,2) summarywave //I usually include overwrite because I run things over and over and don't want to create new ones all the time

  // optional but I like to label my dimensions and then use labels so I don't need to track exact indices
   setdimlabel 1,0,Mean,Summarywave
   setdimlabel 1,1,sd,Summarywave

  variable index // i usually use "index" since the template insertion uses that and I don't have rename

   for(index=0;index<10;index+=1)
     summarywave[index][%mean] = mean(ydw,index*10,index*10+9)
     summarywave[index][%sd]     = sqrt(variance(ydw,index*10,index*10+9))
   endfor
End






Andy



my sections are continuous. So I would put your code in to the procedure window and it will calculate the averages but how do I put these values into a new table?