From: David Heslop on 14 Jan 2010 03:39 Hi all, I’m working with experimental data which is represented as a series of x and y values (both x and y are non-negative), which when plotted give a curved form. I know from theory that they should follow a hyperbolic curve of the form Ax+Bxy+Cy+D=0 and the question is how to determine A, B, C and D for the best-fit hyperbola through the data. Currently I’m using fminsearch to minimize the function: function rs = myfun(coef,x,y) rs=[x x.*y y ones(size(x))]*coef; rs=sum(rs.^2); Where coef is a 4 element column vector containing A, B, C and D. This seems to work okay sometimes, but of course is very sensitive to the initial choices of the coefficients and I really don’t know how robust such an approach is. Does anyone have any suggestions on a more suitable way to fit such a function? Thanks, Dave
From: Torsten Hennig on 13 Jan 2010 18:47 > Hi all, > I'm working with experimental data which is > represented as a series of x and y values (both x and > y are non-negative), which when plotted give a curved > form. I know from theory that they should follow a > hyperbolic curve of the form Ax+Bxy+Cy+D=0 and the > question is how to determine A, B, C and D for the > best-fit hyperbola through the data. Currently > I'm using fminsearch to minimize the function: > > function rs = myfun(coef,x,y) > rs=[x x.*y y ones(size(x))]*coef; > rs=sum(rs.^2); > > Where coef is a 4 element column vector containing A, > B, C and D. This seems to work okay sometimes, but of > course is very sensitive to the initial choices of > the coefficients and I really don't know how > robust such an approach is. Does anyone have any > suggestions on a more suitable way to fit such a > function? > > Thanks, Dave If M is the matrix with rows [x_i; y_i*x_i; y_i ; 1], solve the eigenvalue problem M^t * M * v = lambda * v by using MATLAB's eig-function. The eigenvector v (normalized such that ||v||=1) corresponding to the smallest eigenvalue is the solution to your problem (v=(A,B,C,D)) Best wishes Torsten.
From: Torsten Hennig on 13 Jan 2010 19:29 > Hi all, > I'm working with experimental data which is > represented as a series of x and y values (both x and > y are non-negative), which when plotted give a curved > form. I know from theory that they should follow a > hyperbolic curve of the form Ax+Bxy+Cy+D=0 and the > question is how to determine A, B, C and D for the > best-fit hyperbola through the data. Currently > I'm using fminsearch to minimize the function: > > function rs = myfun(coef,x,y) > rs=[x x.*y y ones(size(x))]*coef; > rs=sum(rs.^2); > > Where coef is a 4 element column vector containing A, > B, C and D. This seems to work okay sometimes, but of > course is very sensitive to the initial choices of > the coefficients and I really don't know how > robust such an approach is. Does anyone have any > suggestions on a more suitable way to fit such a > function? > > Thanks, Dave By the way: For the function you are trying to minimize (A,B,C,D) = (0,0,0,0) is always a solution - and that's not what you want, I guess. Best wishes Torsten.
From: David Heslop on 14 Jan 2010 05:48 Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote in message <232688810.68193.1263464973633.JavaMail.root(a)gallium.mathforum.org>... > > Hi all, > > I’m working with experimental data which is > > represented as a series of x and y values (both x and > > y are non-negative), which when plotted give a curved > > form. I know from theory that they should follow a > > hyperbolic curve of the form Ax+Bxy+Cy+D=0 and the > > question is how to determine A, B, C and D for the > > best-fit hyperbola through the data. Currently > > I’m using fminsearch to minimize the function: > > > > function rs = myfun(coef,x,y) > > rs=[x x.*y y ones(size(x))]*coef; > > rs=sum(rs.^2); > > > > Where coef is a 4 element column vector containing A, > > B, C and D. This seems to work okay sometimes, but of > > course is very sensitive to the initial choices of > > the coefficients and I really don’t know how > > robust such an approach is. Does anyone have any > > suggestions on a more suitable way to fit such a > > function? > > > > Thanks, Dave > > By the way: > For the function you are trying to minimize > (A,B,C,D) = (0,0,0,0) is always a solution - > and that's not what you want, I guess. > > Best wishes > Torsten. Hi Torsten Your right, (A,B,C,D) = (0,0,0,0) isn't what I want. I tried the method you suggested and it works really nicely. One issue appears when I artificially add relatively small amounts of noise to the system (just scaled normally distributed random numbers). Then the fit can be a long way from the data, any suggestions? thanks for your help, Dave
From: Steven Lord on 14 Jan 2010 09:16 "David Heslop" <david_heslop(a)xyz.com> wrote in message news:himl76$2ne$1(a)fred.mathworks.com... > Hi all, > I’m working with experimental data which is represented as a series > of x and y values (both x and y are non-negative), which when plotted give > a curved form. I know from theory that they should follow a hyperbolic > curve of the form Ax+Bxy+Cy+D=0 and the question is how to determine A, B, > C and D for the best-fit hyperbola through the data. Currently I’m > using fminsearch to minimize the function: > > function rs = myfun(coef,x,y) > rs=[x x.*y y ones(size(x))]*coef; > rs=sum(rs.^2); > > Where coef is a 4 element column vector containing A, B, C and D. This > seems to work okay sometimes, but of course is very sensitive to the > initial choices of the coefficients and I really don’t know how > robust such an approach is. Does anyone have any suggestions on a more > suitable way to fit such a function? I would try to transform this into a problem of the form M*coeffs = 0 and use NULL. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Next
|
Last
Pages: 1 2 Prev: How to specify color for new values ? Next: how you change opencv function to matlab |