Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 使用优化工具时如何使用输入参数?_Matlab_Optimization - Fatal编程技术网

Matlab 使用优化工具时如何使用输入参数?

Matlab 使用优化工具时如何使用输入参数?,matlab,optimization,Matlab,Optimization,main.m 我的乐趣 ... param = ...; x0 = [0,0]; [newX, fval] = fminimax(@myfun, x0) ... 如何将参数“param”传递到myfun文件 我试图喜欢以下内容,但出现了错误 function f = myfun(x) f(1)=function of (x, param); f(2)=another function of (x, param); f(3)=... ... f(5)=the last fu

main.m

我的乐趣

...
param = ...;
x0 = [0,0];
[newX, fval] = fminimax(@myfun, x0)
...
如何将参数“param”传递到myfun文件


我试图喜欢以下内容,但出现了错误

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


总的来说,您希望创建新函数。像这样:

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
如需进一步参考,请查看:

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
param = ...;
myfuncinclparam = @(x0)myfun(x0,param)
x0 = [0,0];
[newX, fval] = fminimax(@myfuncinclparam, x0)