I am creating a function that counts the number of digits in an integer. The answer keeps coming out as zero however. It's late and I am probably overlooking something very simple. Thanks.
function [ count ] = CountDigits( input )
s = int2str(input); % convert the input to a string
count = 0; % initialize count to zero
n = length(s); % total length of s
for k = 1 : 1 : n
if s(1,k) >= '0' && s(1,k) <= '9' % is digit
count = count + 1; % add to count if digit
end
end
end