## Procedure to divide waves like with wave arithmetic panel

Krafter | April 8, 2018 - 23:44 | ||
---|---|---|---|

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. 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. ﾕ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. |

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).

Joined: 2007-08-28

Location: Canada

see also

`displayHelpTopic "Waveform Arithmetic and Assignment"`

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: http://www.igorexchange.com/node/8273

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.

support@wavemetrics.com