Find local extremes and flat intermediate values with average values
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
Image Analyst
el 6 de Mzo. de 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
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!