Wave math question
noxidxela
In my program, I want to subtract one wave from another. However the way my data is collected causes the waves to be aligned by x value, not by point (i.e. zero time does not fall on the same point for each wave). If I just subtract the waves normally (wave3=wave1-wave2), it subtracts by point and my waves are not aligned.
Is there a simple way to subtract waves by x instead of by point?
Thanks
-Alex
Do you have x-waves? if so you could interpolate wave2 at the x-values of wave 1 and subtract.
wave wave1, wave1x, wave2, wave2x, wave3
for(i=0; i<numpnts(wave1); i+=1)
x = wave1x[i]
wave3 = wave1 - interp(x, wave2x, wave2)
endfor
July 26, 2013 at 09:12 am - Permalink
wave3 = wave1(x) - wave2(x)
The round parentheses indicate indexing by X value.
If the X scaling of the three waves is not coincident, you may want to take a look at the Wave Arithmetic package: Analysis menu->Packages->Wave Arithmetic. There is a demo: File->Example Experiments->Analysis->Wave Arithmetic Panel Demo.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 26, 2013 at 09:13 am - Permalink
you will get an error if any X value of wave3 is out of range for either wave1 or wave2.
You can do this:
wave3(x0,x1) = wave1(x) - wave2(x)
where x0 is the smallest x value that is valid for both wave1 and wave2 and x1 is the largest X value that is valid for both wave1 and wave2.
Or you can construct wave3 and set its X scaling so that its range of X values is valid for both wave1 and wave2.
As John noted, Wave Arithmetic Panel Demo handles this for you. It also handles the case of XY pairs, I think.
July 26, 2013 at 11:06 am - Permalink
Yes, it does.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 26, 2013 at 04:11 pm - Permalink