How do i find points where slope is zero.

49 ビュー (過去 30 日間)
Eirikur Bernharðsson
Eirikur Bernharðsson 2019 年 10 月 14 日
コメント済み: Star Strider 2019 年 10 月 15 日
I dealing with data from an experiment and i need to find local equivalents or the points where slope is zero.
I tried it in the code as you can see in graph (the red circles), I could find a couple, but the rest dont have the slope exactly zero.
So anyone know if its possible to find the top point or the equivalents.
clc
gogn = xlsread(fullfile('C:\Users\ebben\Dropbox\HR\Eðlisfræði\Verklegt\Top','TOP_gogn.xlsx'));
angle = gogn(:,3); % Exstracting data from excel doc
time = gogn(:,4);
scl = find(angle==min(angle));
time = time(scl:numel(time)); % deleting data in beginning thats not important
angle = angle(scl:numel(angle));
stilling = angle(numel(angle)); % Adjusting to fit x-axis = 0
angle = angle + abs(stilling);
plot(time,angle,'Linewidth',1.5) % plotting and designing graph
xlabel('Time[sec]');
ylabel('Angle[rad]');
grid
hold on
dx_time1 = mean(diff(time)); % trying to find where slope is zero
dy_angle = gradient(angle,dx_time1);
n=1;
slope_angle = dy_angle(1)
for i=1:numel(time)
slope_angle = dy_angle(i);
if slope_angle == 0
inti(n)=i;
n=n+1;
end
end
for i=1:numel(vec)
% for lykkja sem plottar upp punktana á graf
plot(time(vec(i)),angle(vec(i)),'rO','markersize',10)
hold on
end
Capture.JPG

採用された回答

Star Strider
Star Strider 2019 年 10 月 14 日
If you want to use the gradient function to find the inflection points, and since you are dealing with finite-precision values, one approach would be to use linspace and interp1 to create a much higher resolution ‘time’ vector, and then interpolate the ‘angle’ vector to it.
Also, using a tolerance rather than a specific value here:
if slope_angle <= 1E-4
or something similar, might be more appropriate.
However, since you want to find the maxima and minima, the easiest approach would be to use the findpeaks function on the signal and its negative value (to find the minima), or the islocalmax and islocalmin functions to do the same.
It depends on what approach you want to take, and the constraints of your data and data processing.
  2 件のコメント
Eirikur Bernharðsson
Eirikur Bernharðsson 2019 年 10 月 15 日
MVP. didnt know about the findpeaks function.
Star Strider
Star Strider 2019 年 10 月 15 日
Neither did I a few years ago!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePreprocessing Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by