Help me determine why the Isolocalmax doesn't work after applying MinProminence.

3 views (last 30 days)
% Identify indirect peak values (aka vallies)
dataDirect = dataOut;
x = 1: (length(dataDirect));
[ TFm, Pm] = islocalmax(dataDirect);
min_localmax = (mode(dataDirect(TFm))+ mean(dataDirect(TFm)))/2;
% max2 = max(dataDirect);
% max_minlimit2 = max2*.9990;
[ TFd, Pd] = islocalmax(dataDirect, 'MinProminence', min_localmax);% max_minlimit2); % aveDiff,
Peak_location1 = (x(TFd))';
Peak_values1 = dataDirect(TFd);
nexttile
hold on
yline(min_localmax,'r-')
plot(x, dataDirect,x(TFd),dataDirect(TFd),'r*')
title('butter ')
For some reason, the islocalmax function is not identifying any peaks when I use 'MinProminence.' If anyone could suggest alternative functions that would be great. The 'islocalmax' works well when I am trying to determine by 'MinProminence' value but after that it no longer works and I can't figure out why since I use this function all of the time.
If anyone has the time to help I would really appreciate it!

Answers (1)

Star Strider
Star Strider on 31 Mar 2024 at 15:18
Edited: Star Strider on 31 Mar 2024 at 17:00
You need to check the variable values.
I cannot run this here (the Run feature is currently not working, at least for me, although MATLAB Online works), however running this:
dataOut = randn(500,1);
dataDirect = dataOut;
x = 1: (length(dataDirect));
[ TFm, Pm] = islocalmax(dataDirect);
min_localmax = (mode(dataDirect(TFm))+ mean(dataDirect(TFm)))/2
datamax = max(dataOut) % Added
minPM = min(Pm(Pm ~= 0 ))
produces this result:
min_localmax =
-0.2613
datamax =
3.5784
minPM =
0.0082
So I suspect using an extremely low value for 'MinProminence' (much less than the lowest prominence value returned) is likely the problem.
EDIT — (31 Mar 2024 at 17:00)
Corrected typographical errors.
.

Categories

Find more on Preprocessing Data in Help Center and File Exchange

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!