Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: running other applications
Date: Fri, 6 Jul 2007 14:20:10 -0400
Organization: The MathWorks, Inc.
Lines: 42
Message-ID: <f6m14q$s4l$1@fred.mathworks.com>
References: <ef5c942.0@webcrossing.raydaftYaTP> <ef5c942.1@webcrossing.raydaftYaTP> <ef5c942.2@webcrossing.raydaftYaTP> <f6lh2p$4ie$1@fred.mathworks.com> <1183731582.111910.293480@w3g2000hsg.googlegroups.com> <ef5c942.6@webcrossing.raydaftYaTP>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1183746010 28821 144.212.105.187 (6 Jul 2007 18:20:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 6 Jul 2007 18:20:10 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:417641




"Jeremy Smith" <smit1729@umn.NOSPAM.edu> wrote in message 
news:ef5c942.6@webcrossing.raydaftYaTP...
> What is the difference between 'system' and '!' besides 'system'
> returning results?

Anything, including % (which normally act as comment characters) that 
appears after ! on the command line or on a line of a script or a function 
is passed verbatim to the system.  In this example, it's as though you typed 
"callFoo % This attempts to call the callFoo function" (without the quotes) 
at the system command prompt.

!callFoo % This attempts to call the callFoo function

With SYSTEM, you control exactly what gets passed to the system.  This 
example just passes "callFoo" to the system to be executed.

system('callFoo') % This attempts to call the callFoo function

> Why is there such a strong aversion to using 'eval'? I realize there
> is usually a better way of accomplishing the task programmatically
> but I tend to see fairly strong opposition to using 'eval' overall.

In my opinion (and the opinions of lots of other posters) it's much harder 
to read something like:

n = 10;
eval(sprintf('a%d = 1:%d', n, n))

than to read:

a{n} = 1:n

EVAL can also be a very good code obfuscation tool.

http://en.wikipedia.org/wiki/Obfuscated_code

-- 
Steve Lord
slord@mathworks.com