# Determining the amplitude of peaks on a slowly changing signal?

2 visualizaciones (últimos 30 días)
HC98 el 11 de Mayo de 2023
Respondida: Shivam Malviya el 17 de Mayo de 2023
So as we all know, findpeaks will return the value of a peak using, e.g.,
[pks locs] = findpeaks(data, x);
My question is, how can I determine the value of the peaks when the function is changing? Normally I could just subtract the height of the function to get just the amplitude of the peaks, discounting the remainding function but now I can't because the function is decreasing.
I suppose my question is, how can I subtract a arying background from my peaks, i.e., isolate their true amplitude if that makes sense?
##### 2 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Mathieu NOE el 17 de Mayo de 2023
problem solved ?

Iniciar sesión para comentar.

### Respuestas (1)

Shivam Malviya el 17 de Mayo de 2023
Hi,
I understand that you are interested in finding how much the peak stands out from the background.
Here are the possible ways to achieve this;
• One way is to use the prominence output of "findpeaks", which measures how much higher a peak is than its neighbouring valleys. This can give an idea of how much the peak stands out from the background. Here is an example of how to do this:
% Create a data with y = x, as a background
f = @(x) x + sin(x*pi);
x = 0:0.1:10;
data = f(x);
% Plot the data by running findpeaks without any output arguments
findpeaks(data) % Execute the findpeaks and get prominence of the peaks
[pks, loc, w, p] = findpeaks(data);
disp("Prominence: " + mat2str(p));
Prominence: [1.10211303259031 1.10211303259031 1.10211303259031 1.10211303259031 1.10211303259031]
• Another way is to subtract the background from the signal or data before using "findpeaks". This can be done by using "smoothdata" to estimate the background and then subtracting it from the original signal or data. Here is an example of how to do this:
% Create a data with y = x, as a background
f = @(x) sin(x/pi) + sin(x*pi);
x = 0:0.1:10;
data = f(x);
% Smoothen the data
backgroundData = smoothdata(data, "movmean", 20);
% Subract the backgroundData from the input data
fastMovingData = data - backgroundData;
% Plot data
plot(x, data)
hold on
plot(x, backgroundData)
plot(x, fastMovingData)
legend("Input Data","Background Data", "Fast Moving Data") % Execute the findpeaks
[pks, loc, w, p] = findpeaks(fastMovingData);
disp("Peaks: " + mat2str(pks));
Peaks: [0.740895126540801 1.02301187483928 1.01888189993183 1.00735436778235 0.992945538896567]
Refer to the following links for a better understanding;
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

R2023a

### Community Treasure Hunt

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

Start Hunting!