Estimate best parameters using lscurvefit

5 次查看(过去 30 天)
Given two datasets x and y. I have a very complicated function f depending on x, y and 3 parameters a=(a1,a2,a3) and want to find the parameters a that minimizes f.
For example lets say i have:
x=[1,2,3,4,5]
y=[1,3,5,7,9]
= +
where is a very complicated function of both a and x and is a complicated function of only a.
With fminsearch, the min value of f could be found by just creating a function of everything
fun = @(X)func(X);
where func is and then use
x0=fminsearch(fun,b)
where b = [b1, b2, b3] is an initial guess
But how can i do it with lscurvefit where i need to state x-data and y-data in the arguments?

回答(1 个)

John D'Errico
John D'Errico 2020-5-27
编辑:John D'Errico 2020-5-27
You are getting lost and confused by the names x and y. They are irrelevant. You have 3 parameters. You have 5 data points, numbered here from 1 to 5. lsqcurvefit does not really care about x and y as such.
Your target here is apparently zero for each such data point.
Just create an objective that evaluates the 5 results, and then returns then to lsqcurvefit, AS A FUNCTION of the parameters.
As easily, you could just use lsqnonlin, since your target is zero anyway for all 5 "data points". Just return the vector f_a.

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by