To find the median you need to sort the array, and if there are an odd number of entries, choose the middle value. If even, average the two values on either side of the middle. There are indeed Arduino libraries for that.
In the Arduino IDE, select tools>manage libraries and enter "median" in the search box. Pick one and install.
jremington:
To find the median you need to sort the array, and if there are an odd number of entries, choose the middle value. If even, average the two values on either side of the middle. There are indeed Arduino libraries for that.
In the Arduino IDE, select tools>manage libraries and enter "median" in the search box. Pick one and install.
You don't actually need to sort an array to find the median. You can do it in linear time: