Find local extremes and flat intermediate values with average values
Ältere Kommentare anzeigen
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?
Antworten (1)
Image Analyst
am 6 Mär. 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 Kommentar
Humberto Munoz
am 7 Mär. 2022
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!