VPA behavior, workaround requested

4 ビュー (過去 30 日間)
lvn
lvn 2015 年 5 月 14 日
コメント済み: Star Strider 2015 年 5 月 14 日
Does anybody now a workaround for this behaviour of vpa?:
syms a b c
c=a+b; a=1; b=1;
vpa(c)
ans =
a + b
while
vpa(a+b)
returns the expected ans=2. I know I could define c after a and b, but in my particular program (the above is just a minimal example), this is not possible. So I am looking for a simple workaround (vpa(char(c)) also does not work).

採用された回答

Star Strider
Star Strider 2015 年 5 月 14 日
Use the subs function inside the vpa call:
syms a b c
c=a+b; a=1; b=1;
vpa(subs(c))
produces:
ans =
2.0
  2 件のコメント
lvn
lvn 2015 年 5 月 14 日
Thanks so much, works great!
Star Strider
Star Strider 2015 年 5 月 14 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by