How should I store the value of f(x) in the output of fsolve?

1 回表示 (過去 30 日間)
Dan Zhu
Dan Zhu 2020 年 6 月 28 日
コメント済み: Dan Zhu 2020 年 10 月 9 日
I saw the example in the fsolve page:
F = @(x) [2*x(1) - x(2) - exp(-x(1));
-x(1) + 2*x(2) - exp(-x(2))];
x0 = [-5;-5];
options = optimoptions('fsolve','Display','iter');
[x,fval] = fsolve(F,x0,options)
which gives the result:
Norm of First-order Trust-region
Iteration Func-count f(x) step optimality radius
0 3 47071.2 2.29e+04 1
1 6 12003.4 1 5.75e+03 1
2 9 3147.02 1 1.47e+03 1
3 12 854.452 1 388 1
4 15 239.527 1 107 1
5 18 67.0412 1 30.8 1
6 21 16.7042 1 9.05 1
7 24 2.42788 1 2.26 1
8 27 0.032658 0.759511 0.206 2.5
9 30 7.03149e-06 0.111927 0.00294 2.5
10 33 3.29525e-13 0.00169132 6.36e-07 2.5
Now, I want to store the last value of f(x), 3.29525e-13, in a file, what should I do?

採用された回答

Matt J
Matt J 2020 年 6 月 28 日
>> norm(fval).^2
ans =
3.2953e-13
  1 件のコメント
Dan Zhu
Dan Zhu 2020 年 10 月 9 日
Thank you, didn't expect it to be that simple.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOptimization についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by