'subs' problem in r2013

1 view (last 30 days)
Sungil Gwon
Sungil Gwon on 27 Dec 2013
Answered: Walter Roberson on 27 Dec 2013
I want to substitute a vector into an equation.
For example,
-------------------
x=1:2;
syms X
Y=X.^2;
y=subs(Y,X,x)
-------------------
Matlab 2012 or previous version gives
y =
1 4
as a 'double' vector.
However, Matlab 2013 gives
y =
[ 1, 4]
as a 'symbolic' vector.
In order to obtain the same result as the first one,
the function 'eval' should be used in r2013.
I don't know why they give different results.
If a scalar is substituted instead of a vector,
They give the same results as a scalar.

Answers (1)

Walter Roberson
Walter Roberson on 27 Dec 2013
Giving a double vector back was arguably wrong and inconsistent. Any time you work with the symbolic toolbox you should expect the result to be symbolic.
If you have a symbolic vector and you want the numeric equivalent, do not use eval(): instead use double()
double(y)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!