Find rising and falling point

31 ビュー (過去 30 日間)
Mirko Tomic
Mirko Tomic 2022 年 6 月 30 日
編集済み: Kevin Holly 2022 年 6 月 30 日
Hi, i need to extract the value with time stamp of the 2 red points from a vector.
Does anyone know an idea or approach for this kind of problem.
TY

採用された回答

Kevin Holly
Kevin Holly 2022 年 6 月 30 日
編集済み: Kevin Holly 2022 年 6 月 30 日
Do you need to know how to find those points given the raw data in a single vector array? If so, see approach below.
Find the slope by finding the difference from the left and then take the absolute value. Find the slopes (datapoints) that are greater than a specific threshold. Note, if you only care about the positive slope (the two red points to the left in the example you provided) then do not take the absolute value. Do the same thing coming from the right. Find the identified datapoints that are common between the left and right approach.
x = 1:11;
y = [0 0 0 0.3 0.8 1 1 1 0.5 0 0];
figure
scatter(x,y,'filled')
threshold = 0.1;
x1 = x(2:end);
y1 = abs(diff(y));
x_left = x1(y1>threshold)
x_left = 1×5
4 5 6 9 10
x2 = flip(x(1:end-1));
y2 = abs(diff(flip(y)));
x_right = x2(y2>threshold)
x_right = 1×5
9 8 5 4 3
values = intersect(x_left,x_right)
values = 1×3
4 5 9
figure
scatter(x,y,'filled')
hold on
scatter(values,y(values),'filled','r')
Approached shown with visualizations:
figure
scatter(x,y,'filled')
Approach from the left
figure
x1 = x(2:end);
y1 = abs(diff(y));
x_left = x1(y1>threshold)
x_left = 1×5
4 5 6 9 10
scatter(x1,y1,'filled')
Approach from the right
figure
x2 = flip(x(1:end-1));
y2 = abs(diff(flip(y)));
x_right = x2(y2>threshold)
x_right = 1×5
9 8 5 4 3
scatter(x2,y2,'filled')
Find the values in common between x_left and x_right.
values = intersect(x_left,x_right)
values = 1×3
4 5 9
figure
scatter(x,y,'filled')
hold on
scatter(values,y(values),'filled','r')

その他の回答 (1 件)

Jonas
Jonas 2022 年 6 月 30 日
編集済み: Jonas 2022 年 6 月 30 日
you can identify those points using a threshold for the differential signal, something like
find( abs(diff(x)) > someThresholdValue )+1
since i dont see the y axis, i cannot suggest a threshold value

カテゴリ

Help Center および File ExchangeParametric Spectral Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by