Code covered by the BSD License  

Highlights from
RoundX - Round to desired precision

5.0

5.0 | 2 ratings Rate this file 14 Downloads (last 30 days) File Size: 1.5 KB File ID: #43745

RoundX - Round to desired precision

by

 

Rounds the elements of X with the desired precision.

| Watch this File

File Information
Description

Rounds the elements of X with the desired precision. Better than similar submissions as it handles arrays, negative and positive precision values, and ceil and floor functionality. It also is very tolerant to different numbers of inputs so it can be used as a direct replacement for round.

%ROUNDX rounds the elements of X with the desired precision
%
% output = roundx(X)
% output = roundx(X, decimalplaces)
% output = roundx(X, decimalplaces, options)
%
% X is the value to be rounded. X can be an array, if desired.
% DECIMALPLACES is the number of decimal places to round to. Also accepts
% 0 and negative values, used to round to desired sig. figs.
% OPTIONS can be 'ceil', 'floor', or 'round' and indicates to the function
% whether to round up, down, or to the closest value, respectively.
% Default is 'round' if excluded.
%
% Author: David Berman (dberm22@gmail.com)

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
11 Jun 2014 Eoghan  
04 Oct 2013 Anne Tishley  

Contact us