Can't get symbolic numbers.
Show older comments
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?
Accepted Answer
More Answers (1)
Hi Austin,
Seems to work here as you expect.
sym(1/5)
sym(1/5,'r')
But the preceeding results are based on the default sympref
sympref
If you change this sympref
sympref('FloatingPointOutput',true);
Then we get
sym(1/5)
sym(1/5,'r')
Maybe you have the FloatingPointOutput = true in your sympref.
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!