For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > Eval(['cd'...] vs cd









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Eval(['cd'...] vs cd
ms

2008-01-31, 10:19 am

Is there any particular reason why you would rather use eval(['cd ' 'c:
\folder']) versus something like cd('c:\folder')? I have noticed both
ways and don't know the difference.
someone

2008-01-31, 8:28 pm

ms <silvertonm@gmail.com> wrote in message <fd580ab7-c839-
444f-a140-d76ecee96868@d4g2000prg.googlegroups.com>...
> Is there any particular reason why you would rather use

eval(['cd ' 'c:
> \folder']) versus something like cd('c:\folder')? I have

noticed both
> ways and don't know the difference.


The general rule of thumb is not to use EVAL unless there
is no other way.

Here is an excerpt from the MATLAB help on "Evaluating
Expressions"

While the eval function can provide a convenient solution
to certain programming challenges, it is best to limit
its use. The main reason is that code that uses eval is
often difficult to read and hard to debug. A second reason
is that eval statements cannot always be translated into C
or C++ code by the MATLAB Compiler.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com