Output a small number as zero
Mostrar comentarios más antiguos
If I type cos(pi/2) the answer comes back as 6.1232e-17 where I know, of course, that the correct answer is zero. What is the best way to get MATLAB intelligently to output zero in place of these very small numbers?
This came up when I was computing a rotation matrix using angles which were simple fractions of pi and one of the elements returned was 24678615572571482867467662723121/6582018229284824168619876730229402019930943462534319453394436096
which ideally would have been rounded to zero.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Number Theory en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!