Why there is no truncate function in Matlab?
82 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I need to truncate values in a For loop and round() isn't working. I was just wondering why there is no truncate function yet?
0 commentaires
Réponse acceptée
Image Analyst
le 24 Août 2017
Because round sometimes rounds up - away from zero. I think you may want to use fix() instead of round(). It always rounds towards zero, in other words, truncates. See if that works for you and let me know.
2 commentaires
Walter Roberson
le 24 Août 2017
You should also know about floor(), which rounds towards negative infinity -- the maximum integer less than or equal to the input.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!