Given a variable x = 12.3442
I want to know the number of decimal digits of the variable. In this case the result would be 4. How can I do this without trial and error?
As mentioned in the comments, the "number of decimal digits" does not make sense in most cases, but I think that this may be what you're looking for:
>> num = 1.23400;
>> temp = regexp(num2str(num),'\.','split')
temp =
'1' '234'
>> length(temp{2})
ans =
3