Addition of ordinate
hch
though I tried a lot I could find the solution for my problem:
I have two datasets with different steps on the x-axis. But I need to perform an addition of the ordinates, i.e. addition of the y-values. Is there a way to do this with IGOR?
Best,
nmr
The solution to the problem depends on the format of your data.
If your data consist of pairs of XY waves, for example {x1,y1} and {x2,y2} then you could create a new x wave which has the desired common sampling rate and use the interp function as follows:
Wave x1,y1,x2,y2
Variable N
Variable dx
Variable x0=min(WaveMin(x1),WaveMin(x2))
Make/O/N=(N)/Free commonXWave=x0+p*dx
Make/O/N=(N) y1New=interp(commonXWave[p],x1,y1)
Make/O/N=(N) y2New=interp(commonXWave[p],x2,y2)
End
You might also want to take a look at the XY Pair to Waveform Panel (just add to your procedure file the statement
compile and check Data Menu->Packages).
In case you simply have two y waves that have different wave scaling:
Wave y1,y2
Variable N
Variable dx
Variable x0=min(DimOffset(y1,0),DimOffset(y2,0))
Make/O/N=(N) y1New,y2New
SetScale/P x (x0),(dx),"", y1New,y2New
y1New=y1(x)
y2New=y2(x)
End
In both cases you need to be careful about the boundaries of your data (e.g., x0 and N*dx may not be common to both waves).
I hope this helps,
A.G.
WaveMetrics, Inc.
December 21, 2010 at 09:46 am - Permalink
To learn more, look at the demo experiment: select File->Example Experiments->Analysis->Wave Arithmetic Panel Demo. There is a substantially upgraded version of the Wave Arithmetic package available with the latest release version 6.21. If you have Igor version 6.0 or later, this is a free upgrade.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
December 21, 2010 at 01:57 pm - Permalink