Is this a bug of MATLAB?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
M. Wang
am 25 Aug. 2024
Kommentiert: Image Analyst
am 25 Aug. 2024
% Here is my code
[vpa(str2sym('asin(1)*2'),100);vpa(str2sym('pi'),100)]
The output is:
3.1415926535897932384626433832795
3.1415926535897932384626433832795
I think the correct answer should be longer. Is it a bug or an expected behavior?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 25 Aug. 2024
Bearbeitet: Stephen23
am 25 Aug. 2024
"I think the correct answer should be longer. Is it a bug or an expected behavior?"
It is not a bug: the default number of digits is 32:
When you create a new symbolic array it will be displayed using the default number of digits:
d = digits
a = vpa(str2sym('asin(1)*2'),100)
b = vpa(str2sym('pi'),100)
c = [a,b] % uses the default number of digits
d = digits(100) % returns the PREVIOUS default digits, set NEW default digits
c = [a,b]
1 Kommentar
Image Analyst
am 25 Aug. 2024
@M. Wang, pi has an infinite number of digits. Obviously not all of them can be displayed. How many digits did you expect to be installed, and how many do you want or need to be displayed?
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!