MATLAB: Suppose i have number a=5.70787644444 how do i consider just first 2 decimal places in that . that is a=5.70. is it possible

MATLABmatlab expressions

please reply as soon as possible.

Best Answer

One solution:
a = 5.70787644444;
roundn = @(x,n) fix(x.*10.^n)./10.^n; % Round ā€˜xā€™ To ā€˜nā€™ Digits To The Right Of The Decimal
ar = roundn(a,2)
produces:
ar =
5.70