disp() output in decimal form
Show older comments
I'm trying to display a table with the values I have stored in some vectors, but when I do it, it shows the results in fractions, and not in decimal form, even though I have tried
format short
The code looks like
disp([' x ', ' y1 ', ' y2 ', ' yex ', 'error1', 'error2'])
disp([xv',y1',y2',yex',error1',error2'])
Where xv, y1, y2, yex, error1 and error2 are row vectors that store the data I want to display (they've been transposed so they appear in columns).
The output looks like
x y1 y2 yex error1 error2
[ 0, 1, 1, 1, 0, 0]
[ 1/40, 1/2, 5/8, exp(-1/2), exp(-1/2) - 1/2, 5/8 - exp(-1/2)]
[ 1/20, 1/4, 25/64, exp(-1), exp(-1) - 1/4, 25/64 - exp(-1)]
[ 3/40, 1/8, 125/512, exp(-3/2), exp(-3/2) - 1/8, 125/512 - exp(-3/2)]
But with more values in the columns, whose fractions start to grow bigger and bigger, like
95367431640625/1152921504606846976
Which makes it pretty annoying and inconvenient.
What could I do to fix this?
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Logical 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!