vpa() examples not working in R2020a

26 次查看(过去 30 天)
I saw that the vpa(x,d) function wasn't working as intended so I tried the examples in https://www.mathworks.com/help/symbolic/vpa.html.
They did not work either:
>> clear all
>> digits
Digits = 32
>> syms x
p = sym(pi);
piVpa = vpa(p)
piVpa =
3.1416
>> vpa(pi,100)
ans =
3.1416
According to the documentation, I should have gotten
piVpa =
3.1415926535897932384626433832795
and
vpa(pi,100)
ans =
3.141592653589793238462643383279502884197169...
39937510582097494459230781640628620899862803...
4825342117068
As you can see, I started my code with
clear all
so I do not know what the problem is.
  3 个评论
Ameer Hamza
Ameer Hamza 2020-9-16
编辑:Ameer Hamza 2020-9-16
Can you show the output of
which vpa -all
Run this in command window.
Hyewon
Hyewon 2020-9-17
version
'9.8.0.1323502 (R2020a)'
%%
which vpa -all
C:\Program Files\MATLAB\R2020a\toolbox\symbolic\symbolic\vpa.m
C:\Program Files\MATLAB\R2020a\toolbox\symbolic\symbolic\@sym\vpa.m % sym method

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2020-9-16
Try:
sympref('default');
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numbers and Precision 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by