MatrixBerryCore
roundn.m
Go to the documentation of this file.
1 function outArr = roundn(inpArr,indexExp)
2 import mxberry.core.throwerror;
3 if ~(isscalar(indexExp)&&(fix(indexExp)==indexExp))
4  throwerror('wrongInput',...
5  'indexExp is expected to be an integer scalar');
6 end
7 %
8 if indexExp < 0
9  multVal = 10 ^ -indexExp;
10  outArr = round(multVal * inpArr) / multVal;
11 elseif indexExp > 0
12  multVal = 10 ^ indexExp;
13  outArr = multVal * round(inpArr / multVal);
14 else
15  outArr = round(inpArr);
16 end
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function roundn(in inpArr, in indexExp)
ROUNDN rounds to multiple of 10^indexExp.