averaging parts of a wave --> write in a new wave
tutor
I would like to average different parts of a wave and write the results in a new wave. The data wave looks like:
{a,a,a,a,a,b,b,b,c,c,c,c,d,d,d,d,d, ..., a,a,a,a,a,b,b,b,c,c,c,c,d,d,d,d,d}
So, the different block of data to average have different number of points, and this sequence of blocks repeats all along the wave.
The final wave should be {avg_a,avg_b, avg_c, avg_d, ...., avg_a,avg_b, avg_c, avg_d}. The point is that I would like also to remove the first point in the a-block, b-block, c-block and d-block when doing the average.
Could you please help me with this? I do not have an easy way to do it ....
Thank you,
T
Do you know how many blocks there are?
Does the wave have unit scaling?
June 30, 2011 at 07:46 pm - Permalink
1. no. of points in each block is known (for example a->5, b->3, c->4, d->5 points in the block)
2. yes, this is also known (in principle this is the no. of point in the row data scan, for each point measured with four different parameters, from here the resulting a,b,c,d blocks)
3. no
thanks!
July 1, 2011 at 03:32 am - Permalink
Function stuffarooney(data, block_lengths)
Wave data, block_lengths
variable ii, jj
duplicate/free data, temp_data
setscale /P x, 0, 1, temp_data
make/d/o/n=0 output
ii = 0
for(; numpnts(temp_data) ; )
jj = mod(ii, numpnts(block_lengths))
redimension/n=(dimsize(output, 0) + 1) output
output[ii] = mean(temp_data, 1, block_lengths[jj] - 1)
ii += 1
deletepoints 0, block_lengths[jj], temp_data
endfor
End
July 3, 2011 at 04:45 pm - Permalink
July 6, 2011 at 06:21 am - Permalink