There are several ways to do this, but first you must determine what is “extreme”? Is it above a certain threshold above a certain number of standard deviations? Or, if you know that you have exactly n these extreme events and that their values are greater than the others, you can use sort and delete the last n elements. etc.
For example, a(a>threshold)=[] takes care of the threshold as a definition, and a(a>mean(a)+n*std(a))=[] takes care of dropping the n standard deviation above the average of a .
A completely different approach is to use the median a , if the vector is as short as you mention, you want to look at the median value, and then you can either generate something higher than some coefficient of this value a(a>n*median(a))=[] .
Finally, a way to evaluate the approach to treating these spikes would be to take a histogram of the data and work from there ...
source share