This
theString - '0'
turns both arguments into doubles with the ASCII values and subtracts them. That is, the '0' value gets subtracted from every digit in theString (which is a vector). So it has the effect of turning theString from a vector of character digits into a vector of numeric digits.
So this
'3603363'
is really a vector of characters, same as
['3','6','0','3','3','6','3']
Then subtracting the '0'
['3','6','0','3','3','6','3'] - '0'
The equivalent double values
[ 51 54 48 51 51 54 51] - 48
So a vector minus a scalar, the scalar gets subtracted from each element
[3 6 0 3 3 6 3]
Then sum( ) simply sums up those digits.
Best Answer