evaluate rising edge sample of a signal

조회 수: 50 (최근 30일)
alessandro mutasci
alessandro mutasci 2021년 8월 24일
댓글: Turlough Hughes 2021년 8월 25일
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
Turlough Hughes
Turlough Hughes 2021년 8월 24일
Can you share the data?
alessandro mutasci
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
Turlough Hughes 2021년 8월 24일
편집: 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:
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
alessandro mutasci
alessandro mutasci 2021년 8월 25일
yes! it's working! thank you so much!
Turlough Hughes
Turlough Hughes 2021년 8월 25일
Glad we got there. If you're happy with that then can you accept the answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by