# How do i find points where slope is zero.

47 ビュー (過去 30 日間)
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
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]');
grid
hold on
dx_time1 = mean(diff(time)); % trying to find where slope is zero
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

### 採用された回答

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 2019 年 10 月 15 日
MVP. didnt know about the findpeaks function.
Star Strider 2019 年 10 月 15 日
Neither did I a few years ago!