How to get answers in decimal form?
62 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all My program is return me answers in x/y form as so, -269871896806271195083/123594766897091545461 How to get answers in decimal form
0 commentaires
Réponses (1)
Walter Roberson
le 4 Mar 2018
I can tell from the range of integers shown that you are using the symbolic toolbox. If the numbers had been smaller, you might possibly have had "format rat" in effect, but "format rat" will not generate numbers with as many digits of precision as we see.
To see a result from the symbolic toolbox in decimal form, either use vpa() or double() on the result. vpa() will return a symbolic number with as much of the input as practical converted to decimal form, and it will leave any unresolved variables intact -- so for example if the input had been symbolic 3*x/2 then it would return 1.5*x without complaining about x being unresolved. double() converts to double precision numbers, but it is unable to deal with unresolved variables.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!