How to convert from symbol to double?
Show older comments
Hi,
I am pretty new to MATLAB, so this might be a stupid question. However, I am encountering a problem when i try to convert a matrix of 1x1 symbols into a matrix with doubles, where the symbols are converted to doubles each. Each element in the matrix is a function of a lot of symbols, which I need somehow to convert into numbers. I have something like this:
syms x y;
f = function of x and y
x = 2;
y = 3;
f.
However, doing this gives me f as a function of the syms x and y, and not the numbers 2 and 3... Hope you can somehow help me, as Im kinda stuck in my coding.
Regards, Christian
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 19 Jan 2013
Edited: Azzi Abdelmalek
on 19 Jan 2013
Use
suyms x
f=cos(x);
x=10;
eval(f)
3 Comments
Walter Roberson
on 19 Jan 2013
No, do not eval() syms!
Alexander Pakakis
on 6 Sep 2019
what should I use instead?
Steven Lord
on 6 Sep 2019
double and subs, as shown in Walter's accepted answer for this question.
Categories
Find more on Numeric Types 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!



