vpa() examples not working in R2020a

29 views (last 30 days)
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 Comments
Hyewon
Hyewon on 17 Sep 2020
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

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 16 Sep 2020
Try:
sympref('default');
.
  1 Comment
Mehmet Hakan Sari
Mehmet Hakan Sari on 1 Oct 2022
This is worked. But I could not get when I broke sym preferences.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!