How do I convert fractional display to decimal display ?
463 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ibrahim A
am 22 Mär. 2021
Kommentiert: Steven Lord
am 22 Mär. 2021
I am getting bunch of fractional values in my output matrix and I have other matrixes outputting the same way as this one. I cannot find a way to change it to decimal notation, something like 1.678.
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 22 Mär. 2021
Call double or vpa on your symbolic variable.
6 Kommentare
Steven Lord
am 22 Mär. 2021
two = sym(2);
sqrt2 = sqrt(two)
V = vpa(sqrt2)
D = double(sqrt2)
whos two sqrt2 V D
V, sqrt2, and two are all sym. So in the code below the line assigning to f(t) creates a symbolic function:
syms t
f(t) = V
D is a double. In the code below assigning to g(t) attempts to store D in element t of the array g.
g(t) = D
Compare:
qdd(t) = V % works
qdd(t) = D % errors
Weitere Antworten (1)
Bjorn Gustavsson
am 22 Mär. 2021
You might have set format to rat somewhere, perhaps in a startup.m or the like. You could get back to more normal decimal output by something like this:
format short g
For additional options check the help and documentation to format.
HTH
Siehe auch
Kategorien
Mehr zu Numbers and Precision finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!