【发布时间】:2012-08-22 10:07:40
【问题描述】:
我正在尝试最小化作为 1x25 向量 (weights_vector) 函数的函数。换句话说,我试图在向量中找到使函数最小化的值。
函数定义为:
function weights_correct = Moo(weights_vector)
corr_matrix = evalin('base', 'corr_matrix');
tolerance = evalin('base', 'tolerance');
returns = evalin('base', 'returns');
weights_correct = weights_vector'*corr_matrix*weights_vector - tolerance*returns'*weights_vector;
end
在这个函数上,我正在调用:
weights_correct = fminsearch(@Moo, weights_vector);
这会重复直到我看到错误
"Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option."
这让我相信我没有正确地最小化。怎么回事?
【问题讨论】:
-
为什么以上帝和小青苹果的名义使用 evalin 将变量带入函数?这将是非常低效的,而且没有充分的理由。了解如何使用匿名函数,您将获得巨大的收益。
-
我知道这不是最佳做法,但您对解决此问题的适当最小化函数有什么建议吗?
-
你能把
weight_vector、tolerance、corr_matrix和returns的内容贴出来吗?然后我可以玩得更好一点......
标签: matlab mathematical-optimization