Duplicating recurring rows
brettkvo
I'm new to the forum, but I will likely become a fixture here. Igor is a new program for me, but my line of grad work requires its use daily. Thanks for fielding my question!
I'm trying to duplicate specific rows from an existing wave into a new wave. For example, say I have 200 rows of data in 4 waves. I would like to put every tenth value from wave1 into a new wave....
How do I go about that?
Thanks!
wave1[1,*;2] = 100 // sets every odd point of wave0
August 24, 2011 at 02:25 pm - Permalink
extract originalWave,resultWave,mod(p,10)==0
will probably do what you want.A
August 24, 2011 at 02:57 pm - Permalink
To extract every tenth value make a wave which has n/10 rows (20 in your case):
make/n=20 newwave
Then use the row counter 'p' in the expression (will count through all rows of newwave, i.e. 0....19):
newwave = wave1[10*(p+1)] // extract point 10, 20, 30, 40, ...
August 25, 2011 at 02:37 am - Permalink
Of course this works as well as my approach. Just be carefull with indexing on the right side of the equation. Your example doesn't extract a value from the first 10 points of wave1 and in return two values from the last 10 points of wave1. Used in a user-defined function compiled with
#pragma rtGlobals=3
, it would actually throw an error, because the index runs to 200.Use
newwave = wave1[10*p+j]
where j is the first point that gets extracted and should be from the interval [0,9]. So choose j=0 (or omit j) if you want to extract points 0, 10, 20, 30, ..., or j=1 to extract the points 1, 11, 21, 31, ..., etc.A
August 25, 2011 at 05:43 am - Permalink