fminsearch to fit data

7 次查看(过去 30 天)
MOH
MOH 2021-10-28
评论: MOH 2021-10-28
how I can pass two varibales and 2 euqations to fit using fminsearch
fminsearch(@(a,c) opt(a,c,x,y),[1,1])
I'm getting below error
>> fminsearch(@(a,c) opt(a,c,x,y),[1,1])
Not enough input arguments.
Error in @(a,c)opt(a,c,x,y)

采纳的回答

Walter Roberson
Walter Roberson 2021-10-28
You cannot pass two variables and two equations to fit to fminsearch()
fminsearch() can work with a vector of variables, but only with one equation.
Your example only shows one function being passed to fminsearch() . You can handle the pair of variables like this:
fminsearch(@(ac) opt(ac(1), ac(2), x, y), [1, 1])
opt() will be responsible for returning a scalar value.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Nonlinear Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by