Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: SOLVE 4 NONLINEAR EQUATIONS (HELP PLEASE) Date: Thu, 29 Apr 2010 22:16:04 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 40 Message-ID: <hrd0f4$4o1$1@fred.mathworks.com> References: <hrcrc2$3me$1@fred.mathworks.com> <hrcs68$r8m$1@fred.mathworks.com> <hrct9s$bpa$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1272579364 4865 172.30.248.38 (29 Apr 2010 22:16:04 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 29 Apr 2010 22:16:04 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:631133 "GAURAV " <gsharda@engineering.uiowa.edu> wrote in message <hrct9s$bpa$1@fred.mathworks.com>... > Hi Roger, > Thanks for your reply.. > > Actually its an assumption I am making. > I have two curves(orthogonal to each other) aligned in 3D ( not necessarily symmetrical ). > The height (along Z axis) is the same. So, when I cut a slice for some Z, I have four points (two from each curve). > Now I need to construct a volume from these two views. So from each slice I am trying to fit in an ellipse. I hope this makes sense. > > So, now I have four points which pass through ellipse and ellipse should not go out of this bound . > So, I am looking to solve the ellipse equation and try to find out of the a,b,xc and yc required for the ellipse with angle=0. > > Can you suggest something? > > Regards, > Gaurav. For the four-point problem you can avoid using one of the non-linear methods by writing your equation in the following linear form. Then use 'svd' to determine the five unknown coefficients: A*x^2 + C*y^2 + D*x + E*y + F = 0 Do this: x = [a1;a2;a3;a4]; y = [b1;b2;b3;b4]; M = [x.^2,y.^2,x,y,ones(4,1)]; [U,S,V] = svd(M); A = V(1,5); C = V(2,5); D = V(3,5); E = V(4,5); F = V(5,5); The fifth column of V has your desired coefficients. These five coefficients should satisfy the above equation. By completion of the squares in the equation and dividing by the appropriate value you can then transform it into your original form and thereby determine a, b, xc, and xc. By way of explanation, this fifth column is the one corresponding to the zero-valued singular value of the matrix M, which causes it to be a solution to the equation. There is bound to be at least one singular value because the number of rows in M is less that its number of columns, and 'svd' always puts the least singular value in the last column - the fifth in this case. Roger Stafford