Symbolic computaion of complex number and using eval function doesnot

14 views (last 30 days)
syms a real;
syms b real;
syms x;
l=a+b*1i;
m=2*a+b*1i;
x=[l m; -m l];
for i= 1:5
a=i;
b=i+1;
eval(x)
end
When I use eval function for this symbolic computation I get output as some real numbers. This just a sample code. Similar logic I am using it in for some problem but the ouput is not coming as desired.
The output eval(x) should come as complex numbers.
Can any one help in this small issue? I would be highly thankful.

Accepted Answer

Walter Roberson
Walter Roberson on 10 Dec 2012
Do not use eval() on symbolic expressions. Symbolic expressions have a different syntax and semantics then MATLAB expressions do.
You should be using subs() instead of eval()

More Answers (0)

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!