how to use property “ProminenceWindow” for command islocalmin
Can someone please explain how to use property "ProminenceWindow" for command islocalmin. I want to understand what difference this ProminenceWindow property can make.
My assumption is i can filter out peak/valley according to the width of the peak/valley(do not confuse width with ‘halfprom’ or ‘halfheight’ in WidthReference property of findpeak. I want to find full prominence width i.e X indices of start of peak and end of peak. using this width can be easily found by subtacting)
i can filter out peak/valley according to the height if i use MinPeakProminence property
Please check below example that i tried for understanding this property.
Example code:
% Generate sample data
x = linspace(0, 3*pi, 1000); % Extended range for gradual changes
y = sin(0.5*pi*x) + 0.01*randn(size(x)); % Half sine wave with very minimal noise
% Define different ProminenceWindow values
prominenceWindows = [5, 20, 50]; % Adjust these values to see the effect
% Create a figure with subplots
figure;
for k = 1:length(prominenceWindows)
% Detect local minima with the current ProminenceWindow
minIdx = islocalmin(y, ‘ProminenceWindow’, prominenceWindows(k));
% Count the number of local minima detected
numMinima = sum(minIdx);
% Create a subplot for the current ProminenceWindow
subplot(length(prominenceWindows), 1, k);
plot(x, y, ‘-b’, ‘DisplayName’, ‘Data’);
hold on;
plot(x(minIdx), y(minIdx), ‘ro’, ‘MarkerFaceColor’, ‘r’, ‘DisplayName’, ‘Local Minima’);
hold off;
legend show;
title([‘ProminenceWindow = ‘, num2str(prominenceWindows(k)), ‘, Count = ‘, num2str(numMinima)]);
xlabel(‘x’);
ylabel(‘y’);
end
% Adjust subplot layout for better visualization
sgtitle(‘Local Minima Detection with Different ProminenceWindow Values’);Can someone please explain how to use property "ProminenceWindow" for command islocalmin. I want to understand what difference this ProminenceWindow property can make.
My assumption is i can filter out peak/valley according to the width of the peak/valley(do not confuse width with ‘halfprom’ or ‘halfheight’ in WidthReference property of findpeak. I want to find full prominence width i.e X indices of start of peak and end of peak. using this width can be easily found by subtacting)
i can filter out peak/valley according to the height if i use MinPeakProminence property
Please check below example that i tried for understanding this property.
Example code:
% Generate sample data
x = linspace(0, 3*pi, 1000); % Extended range for gradual changes
y = sin(0.5*pi*x) + 0.01*randn(size(x)); % Half sine wave with very minimal noise
% Define different ProminenceWindow values
prominenceWindows = [5, 20, 50]; % Adjust these values to see the effect
% Create a figure with subplots
figure;
for k = 1:length(prominenceWindows)
% Detect local minima with the current ProminenceWindow
minIdx = islocalmin(y, ‘ProminenceWindow’, prominenceWindows(k));
% Count the number of local minima detected
numMinima = sum(minIdx);
% Create a subplot for the current ProminenceWindow
subplot(length(prominenceWindows), 1, k);
plot(x, y, ‘-b’, ‘DisplayName’, ‘Data’);
hold on;
plot(x(minIdx), y(minIdx), ‘ro’, ‘MarkerFaceColor’, ‘r’, ‘DisplayName’, ‘Local Minima’);
hold off;
legend show;
title([‘ProminenceWindow = ‘, num2str(prominenceWindows(k)), ‘, Count = ‘, num2str(numMinima)]);
xlabel(‘x’);
ylabel(‘y’);
end
% Adjust subplot layout for better visualization
sgtitle(‘Local Minima Detection with Different ProminenceWindow Values’); Can someone please explain how to use property "ProminenceWindow" for command islocalmin. I want to understand what difference this ProminenceWindow property can make.
My assumption is i can filter out peak/valley according to the width of the peak/valley(do not confuse width with ‘halfprom’ or ‘halfheight’ in WidthReference property of findpeak. I want to find full prominence width i.e X indices of start of peak and end of peak. using this width can be easily found by subtacting)
i can filter out peak/valley according to the height if i use MinPeakProminence property
Please check below example that i tried for understanding this property.
Example code:
% Generate sample data
x = linspace(0, 3*pi, 1000); % Extended range for gradual changes
y = sin(0.5*pi*x) + 0.01*randn(size(x)); % Half sine wave with very minimal noise
% Define different ProminenceWindow values
prominenceWindows = [5, 20, 50]; % Adjust these values to see the effect
% Create a figure with subplots
figure;
for k = 1:length(prominenceWindows)
% Detect local minima with the current ProminenceWindow
minIdx = islocalmin(y, ‘ProminenceWindow’, prominenceWindows(k));
% Count the number of local minima detected
numMinima = sum(minIdx);
% Create a subplot for the current ProminenceWindow
subplot(length(prominenceWindows), 1, k);
plot(x, y, ‘-b’, ‘DisplayName’, ‘Data’);
hold on;
plot(x(minIdx), y(minIdx), ‘ro’, ‘MarkerFaceColor’, ‘r’, ‘DisplayName’, ‘Local Minima’);
hold off;
legend show;
title([‘ProminenceWindow = ‘, num2str(prominenceWindows(k)), ‘, Count = ‘, num2str(numMinima)]);
xlabel(‘x’);
ylabel(‘y’);
end
% Adjust subplot layout for better visualization
sgtitle(‘Local Minima Detection with Different ProminenceWindow Values’); prominencewindow, localmin, localmax, islocalmin, islocalmax MATLAB Answers — New Questions