Path: news.mathworks.com!not-for-mail
From: Alan Weiss <aweiss@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: GA: extra parameters for fitness function
Date: Sun, 07 Dec 2008 21:47:02 -0500
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <ghi1r6$oka$1@fred.mathworks.com>
References: <32843526.1228587243063.JavaMail.jakarta@nitrogen.mathforum.org> <19810651.1228662479564.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: weissa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1228704422 25226 172.31.57.119 (8 Dec 2008 02:47:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 8 Dec 2008 02:47:02 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.18 (Windows/20081105)
In-Reply-To: <19810651.1228662479564.JavaMail.jakarta@nitrogen.mathforum.org>
Xref: news.mathworks.com comp.soft-sys.matlab:505517


SabbeRubbish wrote:
> I've found a solution to this problem, albeit not a very pretty one: using global variables (I know, it's bad practice but in this particular case I couldn't get around it, on such short notice).
> 
> So I just declare my fileName or colorImage as global:
> global colorImage;
> in both files (calling function and called fitness function).

Hi, I'm really sorry you are having this problem. I tried to make it 
much more clear how to do this in the function reference page for ga. 
There is a big note there that points out a section in the Optimization 
Toolbox(TM) User's Guide on how to use anonymous functions or nested 
functions to do this without using global variables:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html

Can you please tell me how I might make this information more visible to 
customers? It is a common problem, and I struggle with informing people.

Alan Weiss
MATLAB mathematical toolbox documentation