fitting data to a superellipse
古いコメントを表示
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); %example
a0 = [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!

3 件のコメント
John D'Errico
2017 年 12 月 25 日
But we don't see your data. There is a very good chance that you have made a very poor choice in how to fit this data, because an ellipse is NOT a function. So best is if you actually attach a .mat file to your question or to a comment. Second best would be to attach a plot of that data.
Saeed
2017 年 12 月 25 日
Saeed
2017 年 12 月 25 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!