radius of a curve in a set of data points
7 views (last 30 days)
Show older comments
I have a set of data points which represents the BH curve of a permanent magnet material. From this set of points, I need to get several parameters as shows the attached picture.

I have managed to get the slope parameters (permeabilities) and the intersection point (coercive force), however I am pretty much struggling to get the Round radius.
The BH curve is defined as two column array with the magnetic field in one column and the flux density in another.

Any help in here is welcome. Thank you.
0 Comments
Answers (2)
John D'Errico
on 16 Oct 2017
You are doing it the wrong way. DON'T think of this as two lines, that you estimate first, and then try to slip a curved arc in there.
Think of it in terms of a circular arc. A circle is defined by a center, thus two numbers. plus a radius. Then you will have two more parameters to estimate - the extent of the arc in degrees (or radians). Thus they will be the start and stop points of the arc, where the circular arc will transition into a straight line.
So now you have just an arc of a circle. At the ends of the arc, compute the tangent line to the circle, and extend that as a ray to infinity.
Solve the problem using a constrained optimization. You have a vector of 5 unknowns.
C_x = v(1)
C_y = v(2)
rad = v(3)
theta1 = v(4)
theta2 = v(5)
So only 5 parameters needed to completely define the curve. Simple constraints:
theta2 >= theta1
r >= 0
You will minimize the sum of squares of the distances to your curve, taken orthogonally to the curve. So a point will be projected down either to the circular arc, or to one of the rays that extend as wings off each end of the arc.
All simple to do, if you are careful. Beware in the case that theta2 or theta1 is effectively 90 or 270 degrees, or close to that point, since then the corresponding ray will be vertical. Carefully written code worries about these problems, so that when they actually happen, your code is robust. And all bad things WILL happen one day to the programmer who writes sloppy code. (Programming karma does exist!)
0 Comments
Image Analyst
on 16 Oct 2017
How about you extract the few points around the kink/knee in the curve and fit them to a circle using the FAQ
function [xc,yc,R,a] = circfit(x,y)
%CIRCFIT Fits a circle in x,y plane
%
% [XC, YC, R, A] = CIRCFIT(X,Y)
% Result is center point (yc,xc) and radius R. A is an optional
% output describing the circle's equation:
%
% x^2+y^2+a(1)*x+a(2)*y+a(3)=0
% by Bucher izhak 25/oct/1991
n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy) sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=A\B;
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3));
You can get the radius from that fit.
1 Comment
John D'Errico
on 16 Oct 2017
Edited: John D'Errico
on 16 Oct 2017
With the caveat that it will not be connected to a line that you also fit to the straight line segments. You need to treat it essentially like a spline if you want a nice continuous (and differentiable) result. If instead, you estimate the separate segments independently, they have no reason or expectation of connecting together.
See Also
Categories
Find more on Interpolation 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!