disp() output in decimal form

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

madhan ravi
madhan ravi on 7 Apr 2019
Use double() or vpa() it looks like the results are from symbolic calculations.

2 Comments

disp(double([xv',y1',y2',yex',error1',error2']))
Thanks!
It really worked.
The results were coming from symbolic calculations indeed.
I didn't think of that.

Sign in to comment.

More Answers (0)

Products

Release

R2018b

Community Treasure Hunt

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

Start Hunting!