How to find inflection point, PLEASE HELP!

157 visualizaciones (últimos 30 días)
Megi Smith
Megi Smith el 20 de Feb. de 2018
Editada: Star Strider el 8 de Jun. de 2020
Hi!I have no experience in Matlab, but I was given the assignment to find point of inflection in this graph. What I have is: x = [ 7.0 7.2 7.4 7.6 8.4 8.8 9.2 9.6 10.0]; y = [ 0.692 0.719 0.723 0.732 0.719 0.712 1.407 1.714 1.99];
I would REALLY appreciate if someone could help me because I don't know what to do and how to find it. Thank you all!
  1 comentario
Rik
Rik el 20 de Feb. de 2018
You should first understand a tool before using it do some work. Also, how general should the solution be? Does it only need to work for this specific data? And how do you define inflection point? The intersection of two linear fits? Some specific point on a more convoluted function?
Some helpful links: Onramp (a crash course in Matlab), tips for a fast answer (and how to find your own) and how to format your question.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 20 de Feb. de 2018
Editada: Star Strider el 8 de Jun. de 2020
Inflection points are defined where the curve changes direction, and the derivative is equal to zero.
See if this does what you want:
x = [ 7.0 7.2 7.4 7.6 8.4 8.8 9.2 9.6 10.0];
y = [ 0.692 0.719 0.723 0.732 0.719 0.712 1.407 1.714 1.99];
dydx = gradient(y) ./ gradient(x); % Derivative Of Unevenly-Sampled Data
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
zxidx = zci(dydx); % Approximate Indices Where ‘dydx=0’
for k1 = 1:numel(zxidx) % Loop Finds ‘x’ & ‘y’ For ‘dydx=0’
inflptx(k1) = interp1(dydx(zxidx(k1):zxidx(k1)+1), x(zxidx(k1):zxidx(k1)+1), 0, 'linear');
inflpty(k1) = interp1(x(zxidx(k1):zxidx(k1)+1), y(zxidx(k1):zxidx(k1)+1), inflptx(k1), 'linear');
end
figure(1)
plot(x, y)
hold on
plot(x, dydx)
plot(inflptx, inflpty, 'pg', 'MarkerFaceColor','g')
hold off
grid
legend('Data', 'Derivative', 'Inflection Points')
inflpts = regexp(sprintf('(%5.3f,%5.3f)\n', [inflptx; inflpty]), '\n', 'split');
text(inflptx, inflpty, inflpts(1:end-1),'FontSize',8, 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
The ‘inflptx’ and ‘inflpty’ vectors (derived from a linear interpolation of the derivative) are the coordinates of the inflection points. They are approximate because your data are discrete. The code does not find an inflection point where what is apparently a spline interpolation might create one, because that is not in your original data.
EDIT — (8 Jun 2020 at 12:21)
While the original code works for the original data here, if the identified zero-crossings of the derivative are close to the ends of the vector, it will crash with indices that exceed the number of vector elements.
This version of the loop fixes that:
for k1 = 1:numel(zxidx) % Loop Finds ‘x’ & ‘y’ For ‘dydx=0’
ixrng = max(zxidx(k1)-2,1):min(zxidx(k1)+2,numel(x));
inflptx(k1) = interp1(dydx(ixrng), x(ixrng), 0, 'linear');
inflpty(k1) = interp1(x(ixrng), y(ixrng), inflptx(k1), 'linear');
end
The ‘inflpts’ assignment also needs to be modified:
inflpts = sprintfc('(%5.3f, %5.3f)', [inflptx; inflpty].');
text(inflptx, inflpty, inflpts,'FontSize',8, 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
.
  6 comentarios
Vishal Rajpurohit
Vishal Rajpurohit el 18 de Jun. de 2018
thank you sir
Adilah R
Adilah R el 8 de Sept. de 2019
then how do I find the y values for those identified inflection points on the spline?

Iniciar sesión para comentar.

Más respuestas (1)

John D'Errico
John D'Errico el 20 de Feb. de 2018
Um, I think you need to look CAREFULLY at the data you have. Then think carefully about what you need.
An inflection point is a location where a curve has a sign change in the second derivative.
Here is your data.
The data seems a bit noisy, although it is hard to know if what I see is noise or true signal. It is also a bit sparse, in the sense that if you truly need to locate a point of inflection, then it is insufficient to do so well.
But, look to the left of the red line. The data there seems to have a fairly simple negative second derivative. To the right of the red line?It is also a region of negative curvature. So essentially everywhere, except at one point, that curve is negatively curved. At the location of the red line, (x==8.8) at best I would see a location where the curve goes through a slope discontinuity. To infer anything more than that from this poor dataset is asking for someone to have a good laugh at your expense.
So, COULD you use a numerical tool (perhaps a spline of some sort) to try to locate an inflection point? Well, yes, in theory, you could try. But the result would be laughably, woefully, poor.
At best, the point of inflection is at x=8.8. See? You did not even need a computer to do that. Just a pair of eyes.

Community Treasure Hunt

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

Start Hunting!

Translated by