WaveMax difference for in-line call

Hi,
I'm normalizing some waves to the maximum value within that wave.
The behavior I see is that using the WaveMax function within a wave assignment statement yields different results than storing the max value in a variable and then reassigning the wave.

In code:

  Make /O/N=1024 Line1 = 5; Line1[600, 750]=35e3;  Duplicate /O Line1 Line2; Variable Line1_Max = WaveMax(line1); Line1 /= Line1_Max; Line2 /= Wavemax(Line2)
 


  Display Line1, Line2; ModifyGraph rgb(Line2)=(0,0,65535)
 


The 2 lines are different after some point.

I've attached an experiment containing the actual data I'm analyzing.

Thanks for your help,
Dave
WaveMax_Oddness.pxp (8.06 MB)
The instruction:
Line2 /= Wavemax(Line2)

evaluates sequentially WaveMax() for each point in the wave Line2 and as elements of the wave are divided, the value returned by WaveMax() also changes.

You should consider using:
Variable nor=WaveMax(Line2)
Line2/=nor


Alternatively:
MatrixOP/O Line2=Line2/maxval(Line2)
Good to know on the internals of WaveMax() -- will use MatrixOP henceforth.

Thanks for the clarification!
Dave_S wrote:
Good to know on the internals of WaveMax() -- will use MatrixOP henceforth.

Thanks for the clarification!

FYI, the result you see has nothing to do with the internals of WaveMax(). If you had used any other function or mathematical operation that, on the right hand side, uses the same wave you are assigning values to, you would have seen something similar.