Function that returns value after decimal point?
Show older comments
Is there a function that returns the value after the decimal?
EX:
a = 2.876
function(a) = 0.876
Thank You
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 4 Oct 2012
Edited: Azzi Abdelmalek
on 4 Oct 2012
out=a-fix(a)
%or
A=num2str(a);
out=str2num(['0' A(strfind(A,'.'):end)])
2 Comments
Jan
on 4 Oct 2012
What happens for integer values?
Azzi Abdelmalek
on 4 Oct 2012
Edited: Azzi Abdelmalek
on 4 Oct 2012
a=1
a-fix(a)=0
and
A=num2str(a);
out=str2num(['0' A(strfind(A,'.'):end)])=0
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!