Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
说我有一个功能
[f,g,h] = function (x)
function.m在Matlab 中的文件中。我怎样才能找到最大化的价值x,例如 using ?该文档仅处理目标函数返回单个值的情况。fminuncgfminunc
function.m
x
fminunc
g
您必须提供fminunc一个返回标量的函数,因此在您的情况下,您只需要声明一个返回的辅助函数g:
g = function helper_func(x) [f, g, h] = func(x);
并将辅助函数输入fminunc:
x = fminunc(@helper_func, x0);