Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail
From: Arthur G <gorramfreak+news@gmail.com>
Newsgroups: comp.soft-sys.matlab
Date: Wed, 19 Mar 2008 11:27:10 -0400
Message-ID: <47e130ce$0$295$b45e6eb0@senator-bedfellow.mit.edu>
References: <26104615.1205870768015.JavaMail.jakarta@nitrogen.mathforum.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Subject: Re: fminsearch matab problem
User-Agent: Unison/1.8
Lines: 24
NNTP-Posting-Host: 18.56.7.23
X-Trace: 1205940430 senator-bedfellow.mit.edu 295 18.56.7.23
Xref: news.mathworks.com comp.soft-sys.matlab:458088



On 2008-03-18 12:05:37 -0400, jimpx <falloncolm@gmail.com> said:

> Hello,
> 
> I want to pass a number of variables through fminsearch. Because of the 
> structure of the program, some of those variables must be held constant 
> while the others are minimized. Is there a way to do this with 
> fminsearch, or is there another minimization program which allows this?
> 
> Thanks,
> 
> jimpx

Write another (possibly anonymous) function that you use with 
fminsearch. This anonymous function has for its inputs only those 
variables you want to minimize with respect to, and others are help 
constant. Here's an example using anonymous functions:

f = @(x,y) (x-y).^2; % A function of two variables
g = @(y) f(3, y); % Function "f", with x=3
yOpt = fminsearch(g, 0);

--Arthur