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

1 vue (au cours des 30 derniers jours)
Dan Zhu
Dan Zhu le 28 Juin 2020
Commenté : Dan Zhu le 9 Oct 2020
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?

Réponse acceptée

Matt J
Matt J le 28 Juin 2020
>> norm(fval).^2
ans =
3.2953e-13
  1 commentaire
Dan Zhu
Dan Zhu le 9 Oct 2020
Thank you, didn't expect it to be that simple.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Optimization dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by