Maximum curvature of a plot
Show older comments
hi I have plotted a polynomial Im interested to get the values of x and y at point of maximum curvature of curve.
Thanks
2 Comments
Krishnakarthika Gorla
on 10 Nov 2019
Can you send the code pls
Krishnakarthika Gorla
on 10 Nov 2019
I want MATLAB code for this
Answers (1)
John D'Errico
on 15 Jun 2014
0 votes
If you have the polynomial, you need to compute the curvature, and then find the maximum value of that function. You can just use fminbnd.
7 Comments
amberly hadden
on 15 Jun 2014
Roger Stafford
on 16 Jun 2014
Jay, John has tried to tell you that if the formula for your curve is that of a known polynomial, then you can compute its curvature directly in terms of the first and second derivatives of the polynomial in accordance with the formula in the web site he referenced.
I'll give you that formula here to help you on your way:
K = d^2y/dx^2/(1+(dy/dx)^2)^(3/2)
where dy/dx is the first derivative and d^2y/dx^2 the second derivative. The value of K is positive if curvature is to the left as x increases and negative if to the right. Thus your task is to find these derivatives of your polynomial function - an easy task - then express the curvature as a function of x - also an easy task - and then finally find where this curvature value is maximum in (presumably) absolute value - a slightly more difficult task. Piece of cake!
On the other hand if you only possess the x,y coordinates of a set of points on some curve, then there is a very different computation that can approximate the curvature in terms of those coordinates.
John D'Errico
on 16 Jun 2014
You said you have a polynomial, not just some general curve. And if it is a polynomial, then you must know what the polynomial is, else you could not have plotted it. Roger has given you the formula for curvature, something pretty simple to evaluate given a polynomial.
amberly hadden
on 16 Jun 2014
John D'Errico
on 16 Jun 2014
NO. NOBODY has said that, except you, and I have no guess how you got that idea. Roger gave you a formula for curvature, which is simple to evaluate for a polynomial. Use it.
amberly hadden
on 16 Jun 2014
Roger Stafford
on 16 Jun 2014
In that case it is "On the other hand" of my last paragraph above. To have used 'cftool' you must have had the coordinates of a set of points that determined your curve. If you are very confident of the accuracy of these points, you can approximate the curvature at a point (x2,y2) by the curvature of the unique circle that goes through the three successive points (x1,y1), (x2,y2), and (x3,y3). I quote the answer I gave in the Answers Thread #58964 on Jan 16, 2013:
"Let (x1,y1), (x2,y2), and (x3,y3) be three successive points on your curve. The curvature of a circle drawn through them is simply four times the area of the triangle formed by the three points divided by the product of its three sides. Using the coordinates of the points this is given by:
K = 2*abs((x2-x1).*(y3-y1)-(x3-x1).*(y2-y1)) ./ ...
sqrt(((x2-x1).^2+(y2-y1).^2)*((x3-x1).^2+(y3-y1).^2)*((x3-x2).^2+(y3-y2).^2));
You can consider this as an approximation to the curve's curvature at the middle point. (x2,y2), of the three points."
I leave it to you to work out how to locate the maximum value of such 'K' values. (Note: If you leave out the 'abs' in this formula, you get the signed version, positive for turning left and negative for turning right.)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!