Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Anonymous function creation from string
Date: Thu, 20 Mar 2008 09:38:37 -0400
Organization: The MathWorks
Lines: 23
Message-ID: <MPG.224c32e9c2fdbe3a989826@news.mathworks.com>
References: <frr1de$7a5$1@fred.mathworks.com>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1206020317 19362 172.31.57.117 (20 Mar 2008 13:38:37 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 20 Mar 2008 13:38:37 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:458277



In article <frr1de$7a5$1@fred.mathworks.com>, 
ngdenmanNOSPAM@gmail.REMOVETHIS.com says...
> Hi
> 
> I have a GUI where the user can enter a function (as a
> string) that is evaluated in another routine. For example,
> the user may enter 'theta(1)*x^2 - theta(2)*x^3'.
> 
> Currently I convert the above string expression to an
> anonymous function by using EVAL, e.g. 
> >> fHnd = eval(['@(x,theta) (',str,')'])
> where str is the string given in the GUI. Can anyone suggest
> a better way of creating the anonymous function without
> using eval?
> 
> Cheers,
> Nick
> 
not sure it will work in your case, but look into str2func.

-- 
Loren
http://blogs.mathworks.com/loren/