|
"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
|