evaluate rising edge sample of a signal

44 ビュー (過去 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 Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by