Code that was working under R2012b and do not work any more under R2016a: fcts solve and eval
Show older comments
Hi, I have following short code that was working under Matlab R2012b (see result below) and do not work any more under R2016a!
Could you examine this!
Thank you
fm = 1000;
BW_Hz = 100;
delta_OMEGA = BW_Hz/fm;
ai = sqrt(2);
bi = 1;
syms x;
y=bi^2*x^8 -delta_OMEGA^2*bi*x^6 +(delta_OMEGA^2*ai^2-2*bi^2-2*delta_OMEGA^2*bi)*x^4 -delta_OMEGA^2*bi*x^2 + bi^2;
alphas1b=solve(y,x)
alphas1c=eval(alphas1b)
R2012b : OK --------
alphas1b =
1.0360030147808337582053932803524
0.96524815635941929264411150626075
-0.96524815635941929264411150626075
-1.0360030147808337582053932803524
- 0.035333235097304614354828859673636 + 0.99937558630254651692473420806315*i
- 0.035333235097304614354828859673636 - 0.99937558630254651692473420806315*i
0.035333235097304614354828859673636 + 0.99937558630254651692473420806315*i
0.035333235097304614354828859673636 - 0.99937558630254651692473420806315*i
alphas1c =
1.0360
0.9652
-0.9652
-1.0360
-0.0353 + 0.9994i
-0.0353 - 0.9994i
0.0353 + 0.9994i
0.0353 - 0.9994i
R2016a : ERRORS --------
alphas1b =
-root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 1)^(1/2)
-root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 2)^(1/2)
-root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 3)^(1/2)
-root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 4)^(1/2)
root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 1)^(1/2)
root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 2)^(1/2)
root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 3)^(1/2)
root(z^4 - z^3/100 - 2*z^2 - z/100 + 1, z, 4)^(1/2)
Error using evalin
Undefined function or variable 'z'.
Error in sym/eval (line 11)
s = evalin('caller',vectorize(map2mat(char(x))));
Accepted Answer
More Answers (1)
Walter Roberson
on 14 Mar 2017
1 vote
Never eval() a symbolic expression. Symbolic expressions are not written in MATLAB: they are in a language that is close to MATLAB.
1 Comment
Stephen23
on 14 Mar 2017
Good luck getting that message across.
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!