I have the following data
data={{1.5, 10}, {25, 26.5}, {29.25, 32.75}, {39.25, 42.5}, {62.5, 67}, {73.5, 80.75}, {87.5, 93}, {102, 104.75}, {111, 114.5}, {123, 129}, {146.5, 152.75}, {161.5, 164.5}, {177, 182.25}, {195.75, 206}, {218.25, 226.25}, {234.75, 237.75}, {246, 252.5}, {258.5, 260.25},{266.25, 272.75}, {280.5, 280.75}, {281.5, 283}, {292,301.25}, {314, 322}, {327.5, 328.5}, {329, 330.25}}
Each set of point denotes the starting and ending point of the pulse, so here there are as many pulses as
Length[data]
I make the function consisting of all these pulses as follows:
f[x_] := Sum[HeavisideTheta[x - Part[data, i, 1]] + HeavisideTheta[-x+Part[data,i,2]], {i, 1, Length[data]}]
This - as it can be checked - uses 2 Heaviside functions to create each pulse. The problem is while plotting the net pulse function:
Plot[f[x], {x, 0, Part[Last[data], 2] + 10}, Filling -> Bottom]
As it can be seen from the "data" list, there are supposed to be the
{146.5, 152.75}, {161.5, 164.5} and {280.5, 280.75}, {281.5, 283}
pulses in the plot that are just missing.
I just can't figure out how this is happening. Any help will be greatly appreciated!
Plot
e.g. these options resolves the problem:PlotPoints -> 200, MaxRecursion -> 4
. $\endgroup$Plot
carefully or take a look at e.g. RegionPlot is producing odd gaps, even for simple functions. Is there an option to prevent this?. There were many similar questions here, you should search for e.g.MaxRecursion
. $\endgroup$