I want to fit an ellipse model to a data. This sample data I extracted from a simple parametric plot of 2 Sin[t], Cos[t]
(Let's say, I don't know that) and I want to fit my model of an ellipse to this data. This is what I have tried:
Sample data:
data = Flatten[ Cases[ParametricPlot[{Cos[t], 2 Sin[t]}, {t, 0, 2 Pi}], Line[data_] :> data, Infinity], 1];
Model:
x^2/a^2 + y^2/b^2 == 1
f[x_]:=Sqrt[(1 - x^2/a^2) b^2];
and,
fit = NonlinearModelFit[data,f[x], {a,b}, x]
It throws me complex infinity error and I am not able to solve it. Any help is appreciated.
data
$\endgroup$y
values. $\endgroup$breg = BoundingRegion[data, "FastEllipse"]
and get a quick and very close approximation to the ellipse which givesEllipsoid[{-0.00227863, 0.00734437}, {{1.00538, 0.0000434228}, {0.0000434228, 4.07901}}]
$\endgroup$