"Christopher Creutzig" <Christopher.Creutzig@mathworks.com> wrote in message news:5124D68E.firstname.lastname@example.org... > 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 peaks; syms alpha % The next line calls the ALPHA function. It does NOT attempt to index into the variable with an index of 0.5 alpha(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.