2
$\begingroup$
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.

$\endgroup$
4
$\begingroup$

one way might be

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

Mathematica graphics

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

Mathematica graphics

$\endgroup$
  • $\begingroup$ How do I specify the number of points which I want to delete. Like not delete all the points but some $\endgroup$ – tabby_kaur May 20 '18 at 6:37
4
$\begingroup$

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]

enter image description here

Length /@ {function, Join @@ dta}

{256, 206}

Original answer:

testF = .10 <= # <= .15 || .6 <= # <= .8 &;
dt = Select[SplitBy[function, testF @ #[[1]]&],   Not @ testF @ #[[1, 1]] &];

ListPlot[Re @ dt,  Joined -> True]

enter image description here

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

enter image description here

$\endgroup$
  • $\begingroup$ How have you defined the number of points to be deleted. $\endgroup$ – tabby_kaur May 20 '18 at 6:27
  • $\begingroup$ @tabby_kaur, please see the update. $\endgroup$ – kglr May 20 '18 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.