# Can't get symbolic numbers.

6 vues (au cours des 30 derniers jours)
Austin Smith le 29 Sep 2023
Réponse apportée : Paul le 29 Sep 2023
I have been trying to get MATLAB to display an answer with symbolic numbers (i.e. fractions like 1/5, 3/8, simple stuff like that), but I cannot get it to work, and I don't know why. I will write sym(1/5) and it outputs 0.2. I have tried using sym(1/5, 'r') and the same thing happens. I have also tried many other things like format rational, rat(1./5), etc, and every time it still outputs 0.2. The 0.2 is symbollic, but I would just like to see it as a fraction. How do I fix this?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Star Strider le 29 Sep 2023
The sympref function should work, specifically:
sympref('FloatingPointOutput',false);
or:
sympref('FloatingPointOutput','default');
since the default is to use symbolic output.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Plus de réponses (1)

Paul le 29 Sep 2023
Hi Austin,
Seems to work here as you expect.
sym(1/5)
ans =
sym(1/5,'r')
ans =
But the preceeding results are based on the default sympref
sympref
ans = struct with fields:
FourierParameters: [1 -1] HeavisideAtOrigin: 1/2 AbbreviateOutput: 1 TypesetOutput: 1 FloatingPointOutput: 0 PolynomialDisplayStyle: 'default' MatrixWithSquareBrackets: 0
If you change this sympref
sympref('FloatingPointOutput',true);
Then we get
sym(1/5)
ans =
0.2000
sym(1/5,'r')
ans =
0.2000
Maybe you have the FloatingPointOutput = true in your sympref.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Assumptions dans Help Center et File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by