Borrar filtros
Borrar filtros

Change a variable's value wherever exists

1 visualización (últimos 30 días)
Vasilis Chasiotis
Vasilis Chasiotis el 22 de Abr. de 2020
Comentada: Deepak Gupta el 22 de Abr. de 2020
I have the following code:
syms a
x = a+1;
a = 2;
However, the value of x is equal to a+1.
Because I put a=2, how can I take the output of x to be equal to 2+1=3?
Thanks

Respuesta aceptada

Deepak Gupta
Deepak Gupta el 22 de Abr. de 2020
Hello Vasilis,
You need to use subs function to calculate value of symbolic function.
subs(x) as last line will give you value of x for a = 2.
Thanks,
Deepal\k
  2 comentarios
Vasilis Chasiotis
Vasilis Chasiotis el 22 de Abr. de 2020
It works! Thanks!
Deepak Gupta
Deepak Gupta el 22 de Abr. de 2020
Welcome Vasilis.
Please mark the answer as accepted if this solves your problem.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Variables, Expressions, Functions, and Preferences en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by