Curve Fitting for an equation

조회 수: 4 (최근 30일)
Jay
Jay 2018년 9월 28일
댓글: Jay 2019년 5월 8일
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
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일
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
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일
Hello,
Did you try cftool? It does have provision of adding custom equations too.
Regards, Pratik
  댓글 수: 4
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by