How to round up all components of a matrix to nearest 'k' decimal
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Antonio
le 14 Nov 2015
Réponse apportée : Walter Roberson
le 14 Nov 2015
Hi,
Does anyone know how I can change this:
d =
0.017869069824194415755502531669223
-0.0050797537564829351997036551331211
-0.0077677772808408665487476505869037
to this:
d =
0.018
-0.005
-0.008
Actually I want to round it up in the 3rd decimal. Thanks.
0 commentaires
Réponse acceptée
Walter Roberson
le 14 Nov 2015
vpa(d,3)
We can tell from the number of decimal places that you show that you must be using symbolic numbers, so you can use vpa() to evaluate to a specific number of decimal places.
There is no way to round double precision numbers to a particular number of decimal places, because 0.1 is not exactly representable as a finite binary floating point number, for the same reasons that 1/7 is not exactly representable as a finite decimal number.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!