Not enough input arguments for multivariable function when using bayesopt.
显示 更早的评论
I want bayesopt to minimize two variables in a particular function. This piece of code works with one function (just var,) but the second I try to add var1 and its corresponding y input into the function all I get is "not enough input arguments." The error sites the "fun = ..." line as the one with the error.
Here is my code and its corresponding error:
var = optimizableVariable('theta',[1,10],'Type','real');
var1 = optimizableVariable('alpha',[1,10],'Type','real');
fun = @(x,y)objfunxx(x.theta, y.alpha); %Create Function Handles
results = bayesopt(fun,[var,var1]);
function f = objfunxx(x,y)
f=y*sin(x);
end
回答(1 个)
Walter Roberson
2023-9-13
0 个投票
fun accepts x, a 1-by-D table of variable values, and returns objective, a real scalar representing the objective function value fun(x).
You on the other hand are expecting the function to be passed two objects
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

