Display symbolic expressions as rational.
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Agustín Rico
le 2 Fév 2021
Commenté : Robert Ukrow
le 26 Jan 2022
How can I display symbolic expressions as rationals? Functions like sympref or vpa allows to display in decimal format, but doesn't provide a way to display symbolic expressions as rationals.
For example:
syms x
(1/2)*(3*x^2)
ans =
1.5000*x^2
Instead of that output I desire the rational expression (or similar):
(3*x^2)/2
1 commentaire
James Tursa
le 2 Fév 2021
That's what I get:
>> syms x
(1/2)*(3*x^2)
ans =
(3*x^2)/2
Do you have something set in preferences that is forcing the decimal output?
Réponse acceptée
madhan ravi
le 2 Fév 2021
Modifié(e) : madhan ravi
le 2 Fév 2021
syms x
sympref('FloatingPointOutput',true);
(1/2)*(3*x^2)
sympref('FloatingPointOutput',false);
(1/2)*(3*x^2)
3 commentaires
Diaa
le 18 Déc 2021
Thanks to you for this answer, and special thanks to google algorithm for bringing me here without wasting my whole day.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Assumptions dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!