Find local extremes and flat intermediate values with average values
Afficher commentaires plus anciens
How do I find the location of the local extreme values of a large data set, and change the values between each two extreme values by their average value?
Réponses (1)
Image Analyst
le 6 Mar 2022
Try this
data = randi(100, 1, 40)
minValue = min(data(:))
maxValue = max(data(:))
meanValue = mean(data(:))
linearIndex1 = find(data(:) == minValue) % Find all occurences of the min value.
linearIndex2 = find(data(:) == maxValue) % Find all occurences of the max value.
allIndexes = sort([linearIndex1; linearIndex2], 'ascend')
data(allIndexes(1) : allIndexes(end)) = meanValue
1 commentaire
Humberto Munoz
le 7 Mar 2022
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!