greeting to the MATLAB community,
xdata=
I have two data sets; xdata and ydata and I need to fit a supperellipse to those data with this line of code.
%%%%%%%%%%%%%%%%%%%
a=2;b=5;p=2;xc=3;yc=1;t=0:pi/20:2*pi;xdata=xc+a*cos(t); %example
ydata=yc+b*sin(t); %examplea0 = [10 10 2]; %inintial guess
options = optimset('Display','iter');c = [xc yc]; %given
%
f = @(aa) (((xdata-c(1)))./aa(1)).^aa(3) + (((ydata-c(2)))./aa(2)).^aa(3) -1; %superellipse Equation
af = lsqnonlin(f, a0, [], [], options);
I used the x&y data of an ellipse with a=2,b=5,xc=3,yc=1
but it returns the following values: af= 9.999999837882097 + 0.000000000000000i 9.999999149008248 + 0.000000000000000i 1.999994717969291 – 0.000007892981223i
which should be colse to 2 5 2
any idea? thanks!
Best Answer