File Exchange

image thumbnail

roundtowardvec

version 2.0.0.2 (2.08 KB) by Tom R
Round a vector of values towards a given vector of choices.

9 Downloads

Updated 14 Dec 2018

View Version History

View License

This function will round an inputed matrix, of any size, and round each value towards the vector of choices given. It can also be given a type of round ('floor','fix','ceil','round','away'), and will round toward -inf,0,inf,closest value, or away from 0 respectively.

Cite As

Tom R (2021). roundtowardvec (https://www.mathworks.com/matlabcentral/fileexchange/37674-roundtowardvec), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Michael

Perfect. Thanks for this :)

Liyuan

needed to tweak, doesn't ignore nans

TordFO

Chris H

Worked great!

Qinmiao Li

Easy to use. Great thanks!

Leonie

super grateful for this easy solution!

Josh Philipson

Joey

This is excellent

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: Round to X

Community Treasure Hunt

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

Start Hunting!