# how to drop certain data points from a list

wo = 2*Pi*50;
tau = 5*Pi;
tstart = 0;
tend = 1;
numpts = 256;
tstep = (tend - tstart)/(numpts - 1);
function =
N[Table[{t,
Exp[-(I wo + tau + 5*\[Pi]) (t)] +
Random[NormalDistribution[0, .1]] +
I Random[NormalDistribution[0, .1]]}, {t, tstart, tend, tstep}]];

ListPlot[Re[function], PlotRange -> All, Joined -> True]


I want to selectively drop certain time points from the function. For example 10 points from t between 0.10 and 0.15 and drop 40 points from t between 0.60 and 0.80.

one way might be

ListPlot[Re[function], PlotRange -> All]


newData  = DeleteCases[function,{t_,_}/;(0.1<t<0.15||0.6<t<0.8)];
ListPlot[Re[newData],PlotRange->All,Joined->True]


• How do I specify the number of points which I want to delete. Like not delete all the points but some May 20, 2018 at 6:37

Update:

How do I specify the number of points which I want to delete. Like not delete all the points but some.

tests = {.10 <= # <= .15 & , .6 <= # <= .8 &};
numberofpointstobedropped = {10, 40};
deleted = Join @@ Table[RandomSample[Position[function, _?(i[[1]][#[[1]]] &), {1},
Heads -> False], UpTo[i[[2]]]], {i, Transpose[{tests, numberofpointstobedropped}]}];
dta = SplitBy[Delete[function, deleted], Or @@ Through @ tests @ #[[1]] &];
ListPlot[Re @ dta,  Joined -> True]


Length /@ {function, Join @@ dta}


{256, 206}

testF = .10 <= # <= .15 || .6 <= # <= .8 &;

Use the option PlotStyle->ColorData[97, "ColorList"][[1]] to get all three pieces in the same color: