# Procedure to divide waves like with wave arithmetic panel

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 :

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

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 :

``````<br />
ﾕDivide root:wave0 / root:wave2<br />
ﾕWave Arithmetic:<br />
AppendToGraph   NewWave  vs  root:NewWave_X<br />
ModifyGraph rgb(  WAr_1  )=(0,0,65535)<br />
``````

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.
Thanks
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).
`displayHelpTopic "Waveform Arithmetic and Assignment"`