# evaluate rising edge sample of a signal

9 次查看（过去 30 天）
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 个评论显示隐藏 1更早的评论
alessandro mutasci 2021-8-24
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 2021-8-24

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') ##### 5 个评论显示隐藏 4更早的评论
Turlough Hughes 2021-8-25
Glad we got there. If you're happy with that then can you accept the answer.

### Community Treasure Hunt

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

Start Hunting!