Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Symbolic expressions
Replies: 3   Last Post: Feb 20, 2013 9:26 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,945
Registered: 12/7/04
Re: Symbolic expressions
Posted: Feb 20, 2013 9:26 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Christopher Creutzig" <Christopher.Creutzig@mathworks.com> wrote in message
> On 16.02.13 15:06, Shishir Jaiswal wrote:
>> I need to define a positive symbolic expression say 'n'.
>> I am using 'sym' or 'syms' (for multiple symbols). In one machine (PC) it
>> is working fine but in another following error is coming:

> Just a quick note: The difference between sym and syms is not whether
> you want a single or multiple symbols. It is true that syms can create
> multiple symbols at the same time, but the primary difference is that
> syms assigns the symbolic variable to the name given:

>>> sym x
> ans =
> x

>>> whos
> Name Size Bytes Class Attributes
> ans 1x1 112 sym

>>> syms x
>>> whos

> Name Size Bytes Class Attributes
> ans 1x1 112 sym
> x 1x1 112 sym
> Also, sym can handle expressions, while syms only defines variables and
> abstract functions. Note that entering expressions into sym is not
> really recommended, since the syntax is subtly different from MATLAB
> expressions.

One more big difference, and the reason I try always to use SYM instead of
SYMS when defining a symbolic variable inside a function, is that SYMS
"poofs" variables into the workspace. The SYM function, when called with an
output argument, does not.

function showpoof
syms alpha
% The next line calls the ALPHA function. It does NOT attempt to index into
the variable with an index of 0.5

beta = sym('beta');
% This next line does NOT call the BETA function.
beta(1, 1)

When you run this, you should see a translucent PEAKS surface (assuming you
have Symbolic Math Toolbox installed) and the variable beta should be
displayed in the Command Window.

Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.