Removing Highest and Lowest Measurements to Average

27 views (last 30 days)
I have a large set of volume measurments I need to sort through. I have about 150 samples and for each sample the instrument measures the volume 10 times and reports all 10. Our procedure is to remove the highest and lowest values and then average the remaining eight. As it stands I've been doing it manually, but with such a large dataset I would prefer to automate it. I'm not even really sure where to start for the matlab code. Selecting out the mins and maxes to make a new list works individually but I don't know how to scale that to 150 samples.
Thanks!
  4 Comments
Image Analyst
Image Analyst on 17 Apr 2021
Edited: Image Analyst on 17 Apr 2021
Sophie, did you even see my Answer below? I also showed you how to process a sequence of files like you asked. It also shows you how to remove the min(s) and max(es) from the list. The Comment above will not remove them all if there is more than one min or max.
Sophie Leiter
Sophie Leiter on 19 Apr 2021
Yes, thank you! I ended up doing a combination of both your answers and it worked well. Thanks for helping me!

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 16 Apr 2021
To process a sequence of files, see code samples in the FAQ:
Once you've read in the data, you can get the min and max and remove them from the sum:
minValue = min(data(:));
maxValue = max(data(:));
% Min and max may occur more than once. Find out how many times they occur.
numMins = sum(data(:) == minValue)
numMaxs = sum(data(:) == maxValue)
theSum = sum(data(:) - numMins * minValue - numMaxs * maxValue)
theMean = theSum / (numel(data) - numMins - numMaxs)

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!