Curve Fitting for an equation

Hello
I have an equation like a*(x1^2)+ b(x2^2)+c((x1-x2)^2)+d((x12)^2)=1. Here I have variables of x1, x2, x12. x12 is the variable in the first quardrant. I have data of 12 Points passing through x1, x2 and x12.
I tried fitting the data to the above equation with different ways. But it did not turned out good. I tried with custom equation and some other methods. Could someone help me with getting the coefficients to this equation.

12 件のコメント

Torsten
Torsten 2018 年 9 月 28 日
Not clear what you are trying to do.
Jay
Jay 2018 年 9 月 28 日
Hello Torsten
I am trying to get the coefficients of the above equation. I have the data points and want to fit the data to the equation.
Thanks
Torsten
Torsten 2018 年 9 月 28 日
編集済み: Torsten 2018 年 9 月 28 日
So given points (x1,y1), (x2,y2),...,(x12,y12), you try to find coefficients a,b,c,d such that the points are best fitted by which function/relation depending on x and y?
Jay
Jay 2018 年 9 月 28 日
Yes exactly.
Torsten
Torsten 2018 年 9 月 28 日
Could you write down the function/relation depending on x and y ?
Jay
Jay 2018 年 9 月 28 日
a*(x^2)+ b(y^2)+c((x-y)^2)+d((x12)^2)=1. Here x12 is another variable (shown in figure).
Torsten
Torsten 2018 年 9 月 28 日
編集済み: Torsten 2018 年 9 月 28 日
What is x12 ? Is it the x-coordinate of the 12th point you want to fit ? Or is it an additional unknown such that you want to fit a,b,c,d and x12 ?
Jay
Jay 2018 年 9 月 28 日
編集済み: Jay 2018 年 9 月 28 日
No, x12 is additional unknown.
Torsten
Torsten 2018 年 9 月 28 日
Sorry, I still don't understand what x12 is.
Given points (-5,-8), (-3,7), (4,6) and (9,-12).
What relations do you want to hold for these 4 points ?
a*(-5)^2+b*(-8)^2+c(-5+8)^2+d*??=1
a*(-3)^2+b*(7)^2+c(-3-7)^2+d*??=1
a*(4)^2+b*(6)^2+c(4-6)^2+d*??=1
a*(9)^2+b*(-12)^2+c(9+12)^2+d*??=1
Image Analyst
Image Analyst 2018 年 9 月 28 日
Jay
Jay 2018 年 9 月 28 日
編集済み: Jay 2018 年 9 月 28 日
Hello Torsten
Okay. Can you just eliminate x12 term from the equation and help for the remaining part (a*(x^2)+ b(y^2)+c((x-y)^2)=1). I want to find the values of a,b,c.
Jay
Jay 2018 年 9 月 28 日
Hello Image Analyst
It is not an Ellipse.

サインインしてコメントする。

 採用された回答

Torsten
Torsten 2018 年 10 月 1 日
編集済み: Torsten 2018 年 10 月 1 日

0 投票

function main
xdata = [...];   % x coordinates of your 12 point
ydata = [...];   % y coordaintes of your 12 points
x0 = [1 1 1];      % initial values for a, b and c
x = lsqnonlin(@(x)fun(x,xdata,ydata),x0)
end
function res = fun(x,xdata,ydata)
res = x(1)*xdata.^2+x(2)*ydata.^2+x(3)*(xdata-ydata).^2-1;
end

4 件のコメント

Jay
Jay 2018 年 10 月 4 日
Thank you Torsten.
Jay
Jay 2019 年 2 月 11 日
Hello Torsten
Could you please help me with plotting this implicit function
Thanks
Torsten
Torsten 2019 年 2 月 11 日
https://de.mathworks.com/help/matlab/ref/fimplicit.html
Jay
Jay 2019 年 5 月 8 日
Hello Torsten
Do you how to implement this code in python?

サインインしてコメントする。

その他の回答 (1 件)

Pratik Bajaria
Pratik Bajaria 2018 年 9 月 28 日

0 投票

Hello,
Did you try cftool? It does have provision of adding custom equations too.
Regards, Pratik

4 件のコメント

Jay
Jay 2018 年 9 月 28 日
Hello Pratik
I tried the cftool as well. It did not worked.
Thanks
Pratik Bajaria
Pratik Bajaria 2018 年 9 月 28 日
Hello,
Go through this example --> (https://in.mathworks.com/help/curvefit/custom-nonlinear-models.html), probably it can help.
Regards, Pratik
Jay
Jay 2018 年 9 月 28 日
Hello
It does'nt work. As I cannot write the above equation as y= f(x).
Pratik Bajaria
Pratik Bajaria 2018 年 9 月 29 日
Well all equations can be written in y=f(x). Take any of the variables to be y (let's say x12) and all the other variables can be x. Since you have data points available try to write x12=f(x1,x2) and it must work.
Regards.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

リリース

R2017b

質問済み:

Jay
2018 年 9 月 28 日

コメント済み:

Jay
2019 年 5 月 8 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by