2017-02-10 33 views
0

的main.m如何在使用优化工具时使用输入参数?

... 
param = ...; 
x0 = [0,0]; 
[newX, fval] = fminimax(@myfun, x0) 
... 

myfun.m

function f = myfun(x) 
    f(1)=function of (x, param); 
    f(2)=another function of (x, param); 
    f(3)=... 
    ... 
    f(5)=the last function of (x, param); 
end 

如何传递参数 'PARAM' 到myfun文件?


我试图喜欢以下,但发生错误。

... 
param = ...; 
x0 = [0,0]; 
[newX, fval] = fminimax(@myfun, x0, param) 
... 

function f = myfun(x, param) 
    f(1)=function of (x, param); 
    f(2)=another function of (x, param); 
    f(3)=... 
    ... 
    f(5)=the last function of (x, param); 
end 

回答

相关问题