MATLAB Answers

VPA behavior, workaround requested

조회 수: 1(최근 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
Star Strider
Star Strider 2015년 5월 14일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변(0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by