|
From: | Andrea Latina |
Subject: | Re: small bug in fminsearch |
Date: | Thu, 8 Aug 2019 12:25:11 +0200 |
On 8/8/19 12:10 AM, Andrea Latina wrote:
> Hello Olaf (as maintainer of the 'optim' package), hello everyone,
>
> I've found a small bug in fminsearch.m in octave 5.1.0 :
>
> line 168 should be
> fval = feval (fun, x, varargin{:});
>
> and not
> fval = feval (fun, x);
>
> Best,
> Andrea
Dear Andrea,
Thank you for the report. Do you want to enable the following calling
scheme?
f = @(x,a) x.^2 + a;
a = 3;
x0 = 1;
[x, fval] = fminsearch (f, x0, [], a)
This behavior is no longer documented by Matlab [1] (but still works in
R2019a). The Mathworks encourages to use anonymous functions instead:
f = @(x,a) x.^2 + a;
a = 3;
fun = @(x)f(x,a);
x0 = 1;
[x, fval] = fminsearch (fun, x0)
This works perfectly in both Octave and Matlab. In bug #55742 [2] it
was recently decided not to support undocumented Matlab features, as
they are more likely to change quietly and are difficult to support and
test.
With best wishes,
Kai
[1] https://www.mathworks.com/help/matlab/ref/fminsearch.html
[2] https://savannah.gnu.org/bugs/?55742
[Prev in Thread] | Current Thread | [Next in Thread] |