Changing indexed values in multiple waves

I have 6 waves that are related and are the same length. There are bad points in one of the waves that I wish to turn into nans. Is there an easy way to change points 10 - 20 to nans in each of the waves without looping or typing in 6 lines of code?  Ideally i would want to apply the range once and have it change all of the waves. The only way I could see it would be this example:

Wave test1,test2,test3,test4,test5,test6

Test1[10,20]=nan; Test2[10,20]=nan; Test3[10,20]=nan; Test4[10,20]=nan; Test5[10,20]=nan; Test6[10,20]=nan

...but then I would have to change the wave range in each instance.


Any help is appreciated, Thanks.



If I understand your desire ... Concatenate the six waves into a matrix (6xN). Set the region matrix[10,20][] = NaN. Split the matrix back to six waves. I think this is three lines of code. :-)

How about:
make wtest
Variable First = 10
Variable Snd = 20
wtest[first, snd] = nan


You can also create one key wave with zero values where you want to keep the original data and 1 where you want to set nans and then apply MatrixOP with the setNaNs() function to each one of the waves.

Could you tell us a bit more about your task? You write about six waves, but it also sounds like a more general procedure ('...I would have to change the wave range in each instance'). I think JJ's answer is the shortest code-wise, but you have certain limitations (same length of all waves, and the 'bad points' have to be at the same position). Is there some way to detect 'bad points'? You could write a mini function to automatically clear these points without manual input, for example.

I do this kind of thing with functions that have more than 6 lines of code :(

function has an optional wave reference wave as parameter; any point removed from target is also removed from waves referenced in waveref wave.

something like this

function ZapBadPoints(wave target, [wave/wave refs])
    if (!ParamIsDefault(refs))
        for (w : refs)
            w = pointisbad(target) ? NaN : w
    target = pointisbad(target) ? NaN : target


Check out SplitWave or use MatrixOP with the Col() function as many times as necessary.

Assuming all your test waves have the same size and are one-dimensional:

Concatenate/NP=1/O "Test1;Test2;Test3;Test4;Test5;Test6;", temp_merged
temp_merged[10,20] = NaN
SplitWave/O/NAME="Test1;Test2;Test3;Test4;Test5;Test6;" temp_merged
KillWaves/Z temp_merged

You can construct the string input for Concatenate and SplitWave dynamically, depending on how many waves you have. You can also go for /FREE instead of the /O flag for Concatenate when you are working inside a function. This would make the KillWaves line unnecessary.

Perfect!! Thanks a lot. I really appreciate the help. Happy Holidays to everyone!!