roundfrac

版本 1.0.0.0 (17.8 KB) 作者: Chad Greene
Round numbers to nearest fraction.
454.0 次下载
更新时间 2015/1/6

查看许可证

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).

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

Description
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'.

引用格式

Chad Greene (2026). roundfrac (https://ww2.mathworks.cn/matlabcentral/fileexchange/48965-roundfrac), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2012b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Arithmetic Operations 的更多信息

roundfrac/html/

版本 已发布 发行说明
1.0.0.0