find the first data points which consecutive increase in value matlab

8 次查看(过去 30 天)
Hi!
I have an time series data where the values starts to increase and decrease. I would like to find the first points where it starts to decrease and where it starts to decrease. And another problem is that after the last endpoint it does not starts decline.
I attach the data and an image which points I would like to find.
I tried before local maxima and minima, but it is not working very well, since the data have some noise and I was unable to overcome the issue with that approach. So I think maybe using the data as a sequnce of a number would be better approach.

回答(1 个)

Image Analyst
Image Analyst 2022-11-8
  2 个评论
Bálint Kovács
Bálint Kovács 2022-11-8
移动:Image Analyst 2022-11-8
It is good to find the first two peaks if I set tresholds, but it does not find the 1. 2. and 3. point and the last point as well :(
Image Analyst
Image Analyst 2022-11-8
Here is a start:
s = load('angle_raw.mat')
s = struct with fields:
Angle: [93480×1 double]
angles = s.Angle;
plot(angles, 'b-');
grid on;
[peakValues, indexesOfPeaks, w, p] = findpeaks(angles, 'MinPeakProminence', 5)
peakValues = 3×1
355.9077 355.7132 356.2584
indexesOfPeaks = 3×1
8126 48196 87798
w = 3×1
1.0e+04 * 1.6867 1.6883 0.4747
p = 3×1
460.2275 460.6227 365.7303
if ~isempty(peakValues)
hold on;
plot(indexesOfPeaks, peakValues, 'rv', 'LineWidth',2)
end
% Find valleys
[valleyValues, indexesOfValleys, w, p] = findpeaks(-angles, 'MinPeakProminence', 5)
valleyValues = 2×1
104.9095 105.0077
indexesOfValleys = 2×1
38387 78446
w = 2×1
1.0e+04 * 2.3173 2.2713
p = 2×1
460.6227 460.9154
valleyValues = -valleyValues;
if ~isempty(valleyValues)
hold on;
plot(indexesOfValleys, valleyValues, 'r^', 'LineWidth',2)
end

请先登录,再进行评论。

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by