Offset wave by first value
azeigle
I'm trying to zero out a 1D wave by offsetting all of the elements by the first value of the wave. I've tried a bunch of things and they all only change the first value. Below are a few of the commands I've tried. I feel like I'm missing something. Is the problem that after zeroing the first value it's subtracting zero from the rest of the elements? I'm looking for something I can run from the command line, not something I'd put in a macro or function.
Make/N=10/D test_wave=5
test_wave = test_wave - test_wave[0]
test_wave = test_wave[p] - test_wave[0]
test_wave = test_wave - test_wave[0]
test_wave = test_wave[p] - test_wave[0]
test_wave[0] is changed the first time through the loop and therefore is 0 for iterations 1 through 4.
For details execute:
DisplayHelpTopic "Don't Use the Destination Wave as a Source Wave"
August 12, 2022 at 07:01 pm - Permalink
Hi,
Create a variable that holds the first value.
Variable offset = test_wave[0]
test_wave -= offset
Andy
August 14, 2022 at 11:27 am - Permalink
In reply to Hi, Create a variable that… by hegedus
Or use:
Mywave[1,]= mywave-mywave[0]; mywave[0]=0
That way any numeric type wave will work with out having to be concerned with the temp variable type. Cases where you might have to do matching include complex and 64 bit integers.
August 18, 2022 at 06:52 pm - Permalink
Andy and Larry, thanks for those solutions. They gave me what I needed to solve my problem.
September 1, 2022 at 10:36 am - Permalink