2017-02-10 72 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 

回答