evaluate rising edge sample of a signal

49 vues (au cours des 30 derniers jours)
alessandro mutasci
alessandro mutasci le 24 Août 2021
Commenté : Turlough Hughes le 25 Août 2021
Good evening, I'm trying to evaluate the rising edge samples of the signal,for each local maximum and minimum, that I have highlighted in red,in the Figure, and put them in a vector. I tried with "islocalmin" to locate the minimum but it wasn't able to locate anything.
Can you give me some advices.
  2 commentaires
Turlough Hughes
Turlough Hughes le 24 Août 2021
Can you share the data?
alessandro mutasci
alessandro mutasci le 24 Août 2021
yes, the vector is attached, I use this for local maximum, [pks, locs] = findpeaks(Mf, 'MinPeakDistance', 50, 'MinPeakHeight', 1); but for the evaluation of the position and the value of the local minimun, so i can do the difference for the 2 positions to evaluate the rising edge sample signal, i don't know how to do it.
I tried [min, locsm] = islocalmin(Mf, 'MinSeparation', 50) and [min, locsm] = islocalmin(Mf, 'FlatSelection', 'last'); but stil nothing.

Connectez-vous pour commenter.

Réponse acceptée

Turlough Hughes
Turlough Hughes le 24 Août 2021
Modifié(e) : Turlough Hughes le 24 Août 2021
Is it just the local minima you're having trouble with?
Edit:
The rising edge is found where the slope of the original data is positive. You can get the start and end of these regions where the slope is positive and they also correspond to the min and max of the rising edge:
load(websave('mf.mat','https://uk.mathworks.com/matlabcentral/answers/uploaded_files/720144/mf.mat'))
dMf = [0; diff(smooth(Mf,'moving',5))];
figure('WindowState','Maximized')
subplot(2,1,1)
plot(Mf);
xlim([1 numel(Mf)])
title('Signal')
set(gca,'fontSize',12)
subplot(2,1,2)
plot(dMf)
xlim([1 numel(Mf)])
title('Slope of Signal')
set(gca,'fontSize',12)
subplot(2,1,1)
idx = dMf > 0; % index for rising edges (where slope > 0).
hold on
plot(find(idx),Mf(idx),'ok','LineWidth',2,'MarkerSize',4)
% Get start and end indices for rising edges.
iStart = find(diff(idx) == 1) + 1;
iEnd = find(diff(idx) == -1) + 1;
if idx(1) == 1
iStart(1) = [1; iStart];
end
if idx(end) == 1
iEnd = [iEnd; numel(idx)];
end
idel = iEnd - iStart <= 20; % threshold size for a group
iEnd(idel) = [];
iStart(idel) = [];
plot(iStart,Mf(iStart),'or','MarkerFaceColor','r','MarkerSize',10)
plot(iEnd,Mf(iEnd),'sr','MarkerFaceColor','r','MarkerSize',10)
legend('Original data','Rising edge','Min','Max','Location','NorthWest')
  5 commentaires
alessandro mutasci
alessandro mutasci le 25 Août 2021
yes! it's working! thank you so much!
Turlough Hughes
Turlough Hughes le 25 Août 2021
Glad we got there. If you're happy with that then can you accept the answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by