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.
我正在使用 fminsearch 来最小化目标函数。这需要将变量 x0(通常是向量)定义为解决方案的估计值,算法将其用作寻找解决方案的起点。但是,我想为每个估计创建许多估计并评估目标函数。我试图将 x0 定义为估计矩阵,但没有得到我想要的结果。
假设每个起始参数向量都存储在 的一行中x0,并且fun是您要最小化的函数:
x0
fun
fun = @(x)100*(x(2) - x(1)^2)^2 + (1 - x(1))^2; x0 = [-1.2, 1; -1.3, 2; 7 3.3]; for i = 1:size(x0,1) x(i,:) = fminsearch(fun,x0(i,:)) endfor
最终输出:
x = 1.00000 1.00001 1.00000 0.99999 0.99997 0.99995