how can i find convex and concave points

조회 수: 22 (최근 30일)
Cem SARIKAYA
Cem SARIKAYA 2019년 5월 15일
댓글: Star Strider 2019년 5월 16일
how do I find the convex and concave points of the discrete data as in the photoWhatsApp Image 2019-05-15 at 5.41.47 PM.jpeg

채택된 답변

Star Strider
Star Strider 2019년 5월 15일
It depends on how you want to define them.
Here, I define them as points where the slope is -0.5:
f = @(x) 1-(x./sqrt(1+x.^2)); % Create Function
x = linspace(-10, 10);
h = x(2)-x(1); % Step Interval
dfdx = gradient(f(x),h); % Derivative
[~,infpt] = min(dfdx);
xpoint(1) = interp1(dfdx(1:infpt-1),x(1:infpt-1),-0.5); % Slope = -0.5
xpoint(2) = interp1(dfdx(infpt+1:end),x(infpt+1:end),-0.5); % Slope = -0.5
figure
plot(x, f(x))
hold on
plot(xpoint, f(xpoint), 'pg', 'MarkerSize',10, 'MarkerFaceColor','g')
hold off
grid
axis('equal')
xlim([-2.5 2.5])
To illustrate:
how can i find convex and concave points - 2019 05 15.png
Your data may be different, so experiment with different values for the slope to get the result you want.
  댓글 수: 9
Cem SARIKAYA
Cem SARIKAYA 2019년 5월 16일
Thank you very much for your time.
Star Strider
Star Strider 2019년 5월 16일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2019년 5월 15일
Depending on what you want to do with this information (which is not clear from the question) you may find the ischange function useful.
f = @(x) 1-(x./sqrt(1+x.^2)); % Create Function
x = linspace(-10, 10);
y = f(x);
changes = ischange(y, 'linear', 'SamplePoints', x);
plot(x, y, '-', x(changes), y(changes), 'gp')
grid on
axis('equal')
xlim([-2.5 2.5])
  댓글 수: 2
Cem SARIKAYA
Cem SARIKAYA 2019년 5월 15일
my data does not have a function, all of my data in the matrix and manually entered values. I need to derive from here or do I need a different code? i actually don't understand. mybe this picture tells you betterWhatsApp Image 2019-05-16 at 1.21.44 AM.jpeg
Adam Danz
Adam Danz 2019년 5월 15일
@Cem SARIKAYA, Steven Lord's proposal is similar to Star Strider's. In the function ischange(), when the method is set to 'linear', the slope of the line is considered and it searches for abrupt changes in the slope.
Again, take a moment to grasp these concepts conceptually before you worry about implementing the code.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by