I have a data list where the elements have the form (time, velocity ). I need to remove some malformed elements in places where the data does not change smoothly and then replace those points by interpolating the elements before and after them.
Here is an example of my data:
{{27.342, -0.01}, {27.443, -0.03}, {27.546, -0.01}, {27.743, -0.01}, {27.945, -0.01},
{28.145, -0.03}, {28.246, -0.05}, {28.346, -0.06}, {28.547, -0.01}, {28.747, -0.01},
{29.149, -0.01}, {29.249, 0}, {29.45, -0.01}, {29.651, -0.05}, {29.852, -0.05},
{30.053, -0.01}, {30.153, -0.01}}
For instance the 7th and 8th elements are malformed since the wind cannot change from -0.3 to -0.05 and -0.6 and then back to -0.01 in 0.1 sec0, so I want to replace them with -0.03 and -0.02.
Differences
reference.wolfram.com/language/ref/Differences.html $\endgroup$Differences
. Then it turns out what you actually want is a filter to replace data if (roughly) the gradient is higher than some value by some interpolated value. But this is only clear from reading the comments. It would help in getting an answer if you included the info from the comments in the question (maybe with a short version of your data and some rough attempt to do what you want). Basically, imagine you don't know what the question is. $\endgroup$