MATLAB: Function that returns value after decimal point

decimalfunctionround

Is there a function that returns the value after the decimal?
EX:
a = 2.876
function(a) = 0.876
Thank You

Best Answer

a = 2.876
b = mod(a, 1)
What is the wanted output for negative numbers? REM might be helpful:
x = -3.14;
mod(x, 1) % 0.86
rem(x, 1) % -0.14
abs(rem(x)) % 0.14

mod(abs(x), 1) % 0.14