Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: str2func with cell input arguments
Date: Mon, 15 Jun 2009 19:20:18 +0000 (UTC)
Organization: Loughborough University
Lines: 14
Message-ID: <h166ti$qpm$1@fred.mathworks.com>
References: <h1666i$8n9$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245093618 27446 172.30.248.37 (15 Jun 2009 19:20:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 15 Jun 2009 19:20:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:547647


"Dave Brackett" <davebrackett@hotmail.com> wrote in message <h1666i$8n9$1@fred.mathworks.com>...
> Up until recently I have been using str2func for specifying some options for an optimisation run. With r2009a this is no longer allowed and I get the error message: "??? Undefined function or method 'str2func' for input arguments of type 'cell'."
> 
> This worked fine in 2008a and I read from Loren's blog that there have been some changes to str2func in the latest release (Starting in Release 2009a, str2func lets you create a handle to anonymous function. Before that, you need to construct an anonymous function from literal strings, or using some ugly code involving eval.). 
> 
> I cannot work out what I need to change to get it to work in my case. Can anyone shed some light on what I'm missing please? Thanks. A snippet of the code is below:
>  
>    options=saoptimset('AnnealingFcn',str2func(current_options.annealing_function),...
>             'TemperatureFcn',str2func(current_options.temperature_function),...
>             'AcceptanceFcn',str2func(current_options.acceptance_function));



ah isn't it always the way that as soon as you post the question, you work out the answer! Simply just needs to use char() to convert from cell. Funny I didn't think of that earlier!