Path: news.mathworks.com!not-for-mail
From: "Yi Cao" <y.cao@cranfield.ac.uk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: eval begone!  (part 2)
Date: Mon, 21 Apr 2008 20:02:02 +0000 (UTC)
Organization: Cranfield University
Lines: 45
Message-ID: <fuirrq$nfb$1@fred.mathworks.com>
References: <fuiqo8$heq$1@fred.mathworks.com>
Reply-To: "Yi Cao" <y.cao@cranfield.ac.uk>
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 1208808122 24043 172.30.248.37 (21 Apr 2008 20:02:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Apr 2008 20:02:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 69713
Xref: news.mathworks.com comp.soft-sys.matlab:464402


"jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message 
<fuiqo8$heq$1@fred.mathworks.com>...
> Hi Matlab folks,
> 
> I am continuing the process of purging eval statements 
from
> my code, but got stuck on another one. Anybody know a way 
to
> avoid eval here? A minimal version of my current code is 
below.
> 
> First, the user gives a file name. Then the name of the 
most
> updated version of a particular routine (which I update
> frequently) is returned by the function 
get_most_recent_func 
> which finds the name of the most recent .m file with the
> base name given by func_basename in the directory 
func_path.
> Finally the most recent function is called (for now using
> eval) with FileName as the argument.
> 
> func_basename = 'my_func';
> FileName = uigetfile;
> func_name = get_most_recent_func(func_path, 
func_basename);
> eval([func_name '(''' FileName ''')']);
> 
> 
> Thanks,
> J

Maybe you can use feval, something like

feval(func_name,FileName)

or

func = str2func(func_name);
func(FileName);

hth
Yi Cao