options = optimset('Display','iter','MaxIter',3,'OutputFcn',@outfun);
[x,fval,~,output] = fminsearch(@(param) esm6(param,identi),result(k,1:end-1),options);
このコードは、esm6 関数のローカルの最小値を見つけ、「表示」オプションにより、このような文字列を出力します
反復 Func-count 分 f(x) 手順
0 1 36.9193
1 5 35.9815 初期シンプレックス
2 7 35.4924 契約内
3 9 35.4924 契約内
4 11 33.0085 拡張
したがって、コマンド ウィンドウで、反復ステップごとに関数 Count を取得します。fminsearch によって作成される構造体output
には、その中に func-count の合計量しかありません。コマンドウィンドウに出力されたすべての情報を出力構造にも受け取る方法はありますか?
編集:
私は解決策にかなり近いと思います。私はこの出力関数を書きました:
function stop = outfun(x,optimvalues,state);
stop = false;
if state == 'iter'
history = evalin('base','history');
history = [history; optimvalues.iteration optimvalues.funcCount];
assignin('base','history',history);
end
end
http://de.mathworks.com/help/matlab/math/output-functions.htmlにより、これは機能するはずですが、実際、matlab は私に、
??? 存在しないフィールド 'funcCount' への参照。
なぜこれが起こるのですか?