MATLAB: How to let the code just consider the demical number ?

decimal; detection

Dear friends
sorry for bothering you guy, can anyone help how to code, asking matlab to only consider the decimal
for example 45.789
I just be coding need to detect the numbers after (.), in another words I need to detect only 789
maybe my question is so silly but sorry due to lack of my knowledge
Thanks a lot guys

Best Answer

Hi Muhammad,
You need the integer part, and the fix function works:
a = 45.789
>> fix(a)
ans = 45
>> b = a-fix(a)
b = 0.7890
For positive a, the floor function gives the same result as fix. However, fix works for both positive and negative a (giving -.789 in the latter case). Floor works as intended only for positive a. See help floor, help fix for the difference in the two functions.
Another way, which also works for both signs, is
b = rem(a,1)