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

 採用された回答

Deepak Gupta
Deepak Gupta 2020 年 4 月 22 日

1 投票

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 件のコメント

Vasilis Chasiotis
Vasilis Chasiotis 2020 年 4 月 22 日
It works! Thanks!
Deepak Gupta
Deepak Gupta 2020 年 4 月 22 日
Welcome Vasilis.
Please mark the answer as accepted if this solves your problem.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Symbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by