MATLAB to Mathematica 4.1
- To: mathgroup at smc.vnet.net
- Subject: [mg30694] MATLAB to Mathematica 4.1
- From: Moranresearch at aol.com
- Date: Sat, 8 Sep 2001 02:22:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Could someone please help translate this six line of MATLAB code into Mathematica? I would like to use this method to fit ellipses to experimental data. Source code for the algorithm is supplied and a beautiful demonstration is available on http://vision.dai.ed.ac.uk/maurizp/ElliFitDemo/demo.htmlThank you. John R Moran PhD, MD % x,y are list of coordinates function a = fit_ellipse(x,y) % Build design matrix D = [x.*x x.*y y.*y x y ones(size(x))]; % Build scatter matrix S = D'*D; % Build 6x6 constarint matrix C(6,6) = 0; C(1,3) = 2; C(2,2) = -1; C(3,1) = 2; % Solve eigensystem [gevec,geval] = eig(inv(S)**C); % Find positive eigenvalue [PosR,PosC] = find(geval > 0 & ~ isinf(geval)); % Extract eigenvector corresponding to positive eigenvalue a = gevec(:,PosC); Source code for the algorithm is supplied and a beautiful demonstration is available on http://vision.dai.ed.ac.uk/maurizp/ElliFitDemo/demo.html
- Follow-Ups:
- Re: MATLAB to Mathematica 4.1
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: MATLAB to Mathematica 4.1