Curve Fitting for an equation
5 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
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 个评论
更多回答(1 个)
Pratik Bajaria
2018-9-28
4 个评论
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 Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!