Round numbers to nearest fraction.

435 descargas

Actualizado 6 Jan 2015

Ver licencia

This function rounds inputs to multiples of a fraction. For example, to round values in an array x to the nearest fifth, use roundfrac(x,1/5).

Xrounded = roundfrac(X,fraction)
Xrounded = roundfrac(X,fraction,option)

Xrounded = roundfrac(X,fraction) rounds X to multiples of nearest fraction. If fraction is a scalar, it is applied to all values in X. If dimensions of fraction match dimensions of X, it is applied element-wise. If fraction is 1/3, values of X are rounded to the nearest one third. roundfrac(X,1) is equivalent to round(X).

Xrounded = roundfrac(X,fraction,option) specifies an option string as 'floor', 'ceil', 'fix', or 'round'. Default rounding option is 'round'.

Citar como

Chad Greene (2023). roundfrac (, MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2012b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Inspirado por: round2, ROUND2, roundn(x,n) returns x rounded to n digits.

Community Treasure Hunt

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

Start Hunting!


Versión Publicado Notas de la versión