1

When using symbolic expression, the question is how to convert symbolic value to discrete value and obtain z value.

x=2
syms x
y=x^2

z=x+y
user9003011
  • 306
  • 1
  • 10
  • Possible duplicate of [Matrix with symbolic Math does not make the calculus](https://stackoverflow.com/questions/45369002/matrix-with-symbolic-math-does-not-make-the-calculus) – Sardar Usama Nov 25 '17 at 18:43
  • See [`subs`](https://www.mathworks.com/help/symbolic/subs.html) and [`sym/double`](https://www.mathworks.com/help/symbolic/double.html). This is pretty basic stuff for symbolic math in Matlab. I recommend that you read through the [documentation](https://www.mathworks.com/help/symbolic/performing-symbolic-computations.html) before proceeding. – horchler Nov 25 '17 at 22:13
  • @Horchler:I searched documentation and googled some search strings. However, I did not reach to what you are pointing at. Perhaps, I wont have posted. But, Jose answer is great and an alternative solution has emerged. – user9003011 Nov 26 '17 at 14:25

1 Answers1

1
syms x y
y = x^2
z = x+y

y_function = matlabFunction(y);
z_function = matlabFunction(z);

x = 2;
z_function(2)