Find local extremes and flat intermediate values with average values

8 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Image Analyst
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
  1 comentario
Humberto Munoz
Humberto Munoz el 7 de Mzo. de 2022
Thank you for the code. I need to give more details of my goals in this project: The data set has two columns, the Resistivity (OHMM) as a function of Depth (FT). The resistivity has many local extremes followed by small deviations over no equally-spaced intervals. I need to determine the location of the peaks in the data set, and transform the function in a step function using the average value over each subinterval (see an example below).
EX: Data = {(1,2),(2,2.1),(3,1.8),(4,8), (5, 8.01), (6,8.2), (7,5), (8,5.2), (9,15), (10,14.8), (11,15.01), (12, 14.9)}
New Data = {(1,1.97),(2,1.97),(3,1.97),(4,8.07), (5, 8.07), (6,8.07), (7,5.15), (8,5.15), (9,14.95), (10,14.95), (11,14.95), (12, 14.95)}
For the local extremes and their location I used successfully the function findpeaks.
For the transformation of the resistivity values, I need to use the meanValue of the values close to each local extreme. I need to find the number of values close to each local extreme. I will thank any help you can give me.
Humberto

Iniciar sesión para comentar.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by