How can I find the local maximum and local minimum in my dataset?

조회 수: 27 (최근 30일)
Farnood83
Farnood83 2021년 7월 24일
댓글: Image Analyst 2021년 7월 25일
I have a dataset of Lateral Force vs Displacement from my experiments. I want to find the local maximums and local minimums in each set of data. Then I need to find the distance between the neighboring local minimum and local maximum. I attached some figures into my question and showed the local maximums and local minimums with circles. The local minimums have a black circle, and local minimums have a red circle.
Is it possible to use findpeaks or islocalmax? I think it might not be possible to use them because my data is not smooth.
Many thanks in advance
Cheers,

채택된 답변

Image Analyst
Image Analyst 2021년 7월 24일
Depends on exactly what you mean by local min or max, and I don't see any black or red circles in the picture you posted. You could try movmin()/imerode() or movmax()/imdilate() to get the min or min in a moving window. The local min in the window may not necessarily be a valley and the local max may not necessarily be a peak. To get peaks and valleys you'd need islocalmin/islocalmax (very simple determination) or findpeaks for a more comprehensive classification of what you call a peak or value. To get valleys you need to invert your signal
[peakValues, indexesOfPeaks] = findpeaks(signal);
[valleyValues, indexesOfValleys] = findpeaks(-signal);
valleyValues = -valleyValues; % Invert back to get the original, non-negated values.
There are a bunch of complicated options in findpeaks() to fine tune what you consder a peak or valley.
  댓글 수: 4
Farnood83
Farnood83 2021년 7월 25일
Some of those are not actually the local maximum or local minimum. Those very small sharp parts of the data are not the main local maximums or local minimums. I just showed some of the major ones to explain what I mean. I will try your suggestion.
Thank you so much
Farnood
Image Analyst
Image Analyst 2021년 7월 25일
Well whatever you want to find, those are the functions that will do it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by