5.0

5.0 | 2 ratings Rate this file 42 downloads (last 30 days) File Size: 5.52 KB File ID: #17804

fminsearchbnd new

by Ken Purchase

 

29 Nov 2007 (Updated 03 Dec 2007)

No BSD License  

improved bounded fminsearch algorithm

Download Now | Watch this File

File Information
Description

A minor improvement on the fminsearchbnd (bounded fminsearch) created by John D'Errico. Changes:

% Changes from fminsearchbnd:
Changes from fminsearchbnd:
1) in options structure, user may pass an 'output function' and 'plot function' to fminsearch.
Original fminsearchbnd handled the output function via a nested wrapper function. I have extended
this to the plot function too.
2) I have moved the 'intrafun' function and wrappers to be nested functions (INSIDE the
fminsearchbnd function), so they do not need to pass the params structure around (into
fminsearch) - but have access to it directly. This
maintains the integrity of the varargin, which the user may be passing thru fminsearch to their
optmization funciton (fminsearchbnd had passed the params structure to fminsearch, thus ruining any
varargin that the user passed in).
3) I have created a test example so the user can see not only how fminseachbnd works, but also how
the OutputFn and PrintFns functions work, which were heretofore poorly documented by MathWorks.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
fminsearchbnd

MATLAB release MATLAB 7.5 (R2007b)
Zip File Content  
Other Files testFMinSearchNew.m,
fminsearchbnd.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
30 Nov 2007 John D'Errico

I'll get to a careful review of this asap, but until I do, I'll note that the optimization toolbox is listed as a requirement. Since fminsearch is part of Matlab, that toolbox should not be necessary. Until then, it looks like Ken has found some things to clean up in my code. If so, well done.

30 Nov 2007 Ken Purchase

Thanks John - I realize I shipped it with a few bugs. I'll update it when I get to the office Monday.

04 Dec 2007 John D'Errico

I like the changes that Ken has made. They clean up the code nicely. Not much to say other than - well done.

29 Mar 2009 Andy

I was going to use this code to fit Gaussians to a known curve by minimizing the known - fit residual. I tried for 3 and 4 Gaussians, meaning 9 or 12 variables. This newer code fails giving the error:

Too many input arguments.

Error in ==> fminsearchbnd>@(x,varargin)fun(xtransform(x),varargin{:}) at 233
    intrafun = @(x, varargin) fun(xtransform(x), varargin{:});

Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});

Error in ==> fminsearchbnd at 264
[xu,fval,exitflag,output] = fminsearch(intrafun,x0u,options,varargin);

The original code by John D'Errico works perfectly.

22 May 2009 Chris Men

good job and thank you very much

Please login to add a comment or rating.
Updates
03 Dec 2007

(Now updated to remove unnecesary commented-out code, and fix a bug in the handling of varargin).

Tag Activity for this File
Tag Applied By Date/Time
optimization Ken Purchase 22 Oct 2008 09:37:17
optimize Ken Purchase 22 Oct 2008 09:37:17
fminsearch Ken Purchase 22 Oct 2008 09:37:17
bound Ken Purchase 22 Oct 2008 09:37:17
bounded Ken Purchase 22 Oct 2008 09:37:17
output Ken Purchase 22 Oct 2008 09:37:17
function Ken Purchase 22 Oct 2008 09:37:17
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com