# evaluate rising edge sample of a signal

5 views (last 30 days)
alessandro mutasci on 24 Aug 2021
Commented: Turlough Hughes on 25 Aug 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 CommentsShowHide 1 older comment
alessandro mutasci on 24 Aug 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.

Turlough Hughes on 24 Aug 2021
Edited: Turlough Hughes on 24 Aug 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:
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') Turlough Hughes on 25 Aug 2021
Glad we got there. If you're happy with that then can you accept the answer.