Procedure to divide waves like with wave arithmetic panel

Posts: 1
Joined: 2018-04-05
Location: France

Hi everyone,

I'm very new to Igor and I'm trying to use macro to automatise something I'm doing.

What I am doing is : I have 4 waves to display 2 curves in a graph. I use crtl+I to place a cursor on each curve. Then I go to Analysis => Wave arithmetic Panel.
In "Wave arithmetic" I select "A/B", "X values from A and B wave" and I got a new wave. I'm using this division because my waves don't have the same lenght / sampling rate, and this work just fine.

So this is what I'm trying to do with a macro. So far I have :

Display wave0 vs wave1; AppendToGraph wave2 vs wave3
•cursor A wave0 1
•cursor B wave2 1
ModifyGraph rgb(wave0)=(0,0,65535)

But I'm stuck here. How can I say to Igor : "now I would divide this wave by the other"? And I want to do the same thing than the arithmetic panel, a "graphic division" that works even with different lengths / sampling rates for the waves.
When I'm doing it manually Igor say this :

  ユDivide root:wave0 / root:wave2
  ユWave Arithmetic:
  	AppendToGraph   NewWave  vs  root:NewWave_X
  	ModifyGraph rgb(  WAr_1  )=(0,0,65535)

But the "ユ" got me a synthax error and without it I got another error "expected wave name".

So this is my problem, I don't know if I'm searching in the right way? If anyone have a solution / suggestion that would help me alot.

Posts: 162
Joined: 2007-08-28
Location: Canada

I've attached a procedure that does something similar. It may help give you a head start. In my case I subtract rather than divide. The code works for mismatched wavelengths if the data are properly scaled as waveform (or for equal sized data that share a common x-values).

ScaleSub.ipf8.35 KB

Posts: 162
Joined: 2007-08-28
Location: Canada

see also
displayHelpTopic "Waveform Arithmetic and Assignment"

Posts: 1936
Joined: 2007-06-29
Location: United States

I have created a function that does a credible job of arithmetic on mismatched XY pairs of waves. I have posted it as a code snippet:

It determines the overlap in X range of the two input X waves and then interpolates a Y value from each input Y wave for each of the input X values that fall within the common X range. So you get a value in the output XY pair for each X input from each input XY pair. It makes no attempt to eliminate duplicate values. If you have identical X values, you should just use plain old Igor-style wave arithmetic.

John Weeks
WaveMetrics, Inc.

Back to top