Hello,
I wondering if somebody could help me,
I need to remove three lines for interval, example: for 4 lines i need to remove 3 leaving 1 intact
thanks so much
I hope I understand you right: You would like to delete every 3 rows/lines out of 4, right? Here is code which deletes all rows besides every nth row:
Function Deleterows(data, every) Wave data //input data Variable every // which nth line to leave
Variablei Variable iteration = floor(Dimsize(data,0)/every) Variable overhead = Dimsize(data,0) - iteration*every for(i=0; i< iteration; i+=1) DeletePointsi,every-1, data endfor if(overhead) DeletePointsi,overhead, data endif End
Now you just need to input into the command line:
Deleterows(yourdataname, 4)
Hope that helps. If you would like to know more about the used commands, just take a look into the help browser.
I hope I understand you right: You would like to delete every 3 rows/lines out of 4, right? Here is code which deletes all rows besides every nth row:
Function Deleterows(data, every) Wave data //input data Variable every // which nth line to leave
Variablei Variable iteration = floor(Dimsize(data,0)/every) Variable overhead = Dimsize(data,0) - iteration*every for(i=0; i< iteration; i+=1) DeletePointsi,every-1, data endfor if(overhead) DeletePointsi,overhead, data endif End
Now you just need to input into the command line:
Deleterows(yourdataname, 4)
Hope that helps. If you would like to know more about the used commands, just take a look into the help browser.
Another way to accomplish this is illustrated here:
•make junk=p// make a fake data wave
•Make/D/n=(numpnts(junk)/4) reduced_junk
•reduced_junk = junk[4*p]
This has the potential advantage of preserving the original data. It also may be faster because it avoids using an explicit loop. I have not tried comparing timings.
I bet AG comes through with a clever way to use MatrixOP...
Just a small comment on deleting points in a wave or characters from a string:
Work through the data backwards ! It avoids to move points-about-to-be-deleted several times and can be MUCH faster (from waiting 10s to "instant")
Wave data //input data
Variable every // which nth line to leave
Variable i
Variable iteration = floor(Dimsize(data,0)/every)
Variable overhead = Dimsize(data,0) - iteration*every
for (i=0; i< iteration; i+=1)
DeletePoints i,every-1, data
endfor
if (overhead)
DeletePoints i,overhead, data
endif
End
Now you just need to input into the command line:
Deleterows(yourdataname, 4)
Hope that helps. If you would like to know more about the used commands, just take a look into the help browser.
June 21, 2017 at 03:10 am - Permalink
Thanks so much it works very well!!
June 21, 2017 at 04:21 am - Permalink
•Make/D/n=(numpnts(junk)/4) reduced_junk
•reduced_junk = junk[4*p]
This has the potential advantage of preserving the original data. It also may be faster because it avoids using an explicit loop. I have not tried comparing timings.
I bet AG comes through with a clever way to use MatrixOP...
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 21, 2017 at 08:28 am - Permalink
wave data
variable every
extract data, wsparse, mod(p,every)==0
end
The new destination wave 'wsparse' is specified and created in the 'extract' command, but could easily be converted to an input specification.
June 21, 2017 at 08:59 am - Permalink
Work through the data backwards ! It avoids to move points-about-to-be-deleted several times and can be MUCH faster (from waiting 10s to "instant")
(adjust the limits)
HJ
June 22, 2017 at 01:12 am - Permalink
June 22, 2017 at 01:44 am - Permalink