finding several values close to the set point

Hello!
I would like to calculate the period in a curve using the mean. However, my attempts to date have not been successful, and I think there is a simple way to do it.
I put random data - eventually I will have a lot of different data and this is to be the method for determining it.
I managed to find the closest value, but unfortunately 1, and I need a few of them to determine the curve's symmetry axis.
Edit: It doesn't search for peaks, because the data on which I work has a few of them on the main peaks, and filtration changes the shape of the plot very much.
Thank you for every advice.
A=[1.5 2.3 3.7 4.6 5.3 4.2 3.8 2.7 1.3 2.6 3.9 4.8 6.1 5.3 4.3 3.6 2.8 1.6 2.4 3.6 4.7 5.4 4.0 2.8 1.5 2.7 3.8 4.7];
A=A';
s = size(A);
t = 1:1:s(1);
plot (t,A)
a = mean(A);
Edit2:
In the attachment I add the real data I work on. From each cell I choose 1 column as X and 3 columns as Y in plot (X, Y).

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 18 de Mzo. de 2020
The following code works by detecting the peak of each cycle and then calculate the average distance between each peak
A=[1.5 2.3 3.7 4.6 5.3 4.2 3.8 2.7 1.3 2.6 3.9 4.8 6.1 5.3 4.3 3.6 2.8 1.6 2.4 3.6 4.7 5.4 4.0 2.8 1.5 2.7 3.8 4.7];
A=A';
t = 1:1:size(A,1);
plot(t,A);
[~, index_peaks] = findpeaks(A);
t_peaks = t(index_peaks);
period = mean(diff(t_peaks));

8 comentarios

Caroline
Caroline el 18 de Mzo. de 2020
Editada: Caroline el 18 de Mzo. de 2020
Unfortunately, the real data has a few peaks on the main peak ... oh I won't work :(
Ameer Hamza
Ameer Hamza el 18 de Mzo. de 2020
In that case, please attach a sample of real data. It will be easy to suggest a working solution using your actual data.
Caroline
Caroline el 18 de Mzo. de 2020
Okay, I added in the attachment.
Check this code
load('test.mat');
a = sila{1};
s = a(:,3);
s = detrend(s);
s_ = s-mean(s);
[~, idx] = findpeaks(s, 'MinPeakProminence', max(s_));
period = mean(diff(idx));
t = 1:numel(s);
plot(t, s, '-', t(idx), s(idx), '+');
It reads the third column and then find the peak of each cycle. It then finds the average difference between peaks to calculate the period.
Caroline
Caroline el 18 de Mzo. de 2020
Thank you very much, this is the first way I was thinking but I couldn't deal with these peaks, Thank you very much !!
Ameer Hamza
Ameer Hamza el 18 de Mzo. de 2020
Glad to be of help.
Caroline
Caroline el 18 de Mzo. de 2020
Analyzing the data, I noticed that the solution has 1 drawback. Peaks occur in different places, therefore the periods are not equal :(.
Ameer Hamza
Ameer Hamza el 18 de Mzo. de 2020
Yes, that can be issue, but since you are taking the average of each interval so this difference is somewhat compensated.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Mzo. de 2020

Comentada:

el 18 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by