New to Igor. How to offset wave data with it mean value

I am new to Igor.
I have some data obtain from a data acquisition system for that I want to demean (offset the entire 1D wave by its mean) and then multiply by a coefficient. Anyone please help.

I tried to do like this:

Make wave16=(wave0-mean(wave0))*1000/11

But it turns out to be a new wave "wave16" with only 128 lines. How can I create a new wave with the same number of values as in the original wave0 (don't want to type manually each time)?

Or is there any "smarter" way to demean a data set (1D wave)

Thank you very much.
eesyliu wrote:

But it turns out to be a new wave "wave16" with only 128 lines. How can I create a new wave with the same number of values as in the original wave0 (don't want to type manually each time)?

Use the Duplicate operation. For example:
Make/N=(1000) wave0 = p
Duplicate/O wave0, wave16


To subtract the mean, you should precalculate the mean and subtract that value instead of doing it how you did it. For example:
Variable wave0Mean = mean(wave0)
Duplicate/O wave0, wave16
wave16 -= wave0Mean
Variable coefficient = 1000 / 11
wave16 *= coefficient


I suggest you go through at least the first half of the Igor guided tour. It will save you a lot of time and help you be much more efficient when using Igor. You can find it by choosing the Help->Getting Started menu item in Igor.
Thank you for your advice.

In fact I have successfully Make a new wave using DimSize such that I don't have to count the number of rows everytime with a new file with different number of rows.

Make /N=(DimSize(wave0,0)) meanwave0= mean(wave0)


This turns out meanwave0 with the same number of rows as wave0 and all rows are filled with mean of wave0.

eesyliu wrote:
Thank you for your advice.

In fact I have successfully Make a new wave using DimSize such that I don't have to count the number of rows everytime with a new file with different number of rows.

Make /N=(DimSize(wave0,0)) meanwave0= mean(wave0)


This turns out meanwave0 with the same number of rows as wave0 and all rows are filled with mean of wave0.


Yes, you can do it like that but that might not be the best way.

The Duplicate operation copies the wave's data as well as other properties such as scaling, dimension labels, the wave note, etc. If you want any of those things copied to your new wave, then I recommend that you use Duplicate instead of Make/N=... to create the new wave.

Also, your make statement is inefficient, as "mean(wave0)" will be calculated for each point in meanwave0. Instead, you should precalculate the mean and then set meanwave0 to be equal to that precalculated value, as in my previous reply. I suspect that you don't even need to create meanwave0 if it is only going to hold the mean value of wave 0 since each point in the wave will be the same.
Thank you and you are right. I just realize my method will recalculate all rows again and again and I can see it is slow. It is better to fill in the same value instead.

Btw, I am thinking to if I can use a running average instead of a fixed mean value.