Assuming that you have a numeric input (either scalar or matrix/vector) and you want to sum the digits only in the even positions (where the first position is considered even), you may do the following steps:
num2str
function.str2num
function.sum
function.Here's a sample code that implements the above steps:
main.m295 chars13 lines
You can test the function by calling it with a numeric input:
main.m44 chars4 lines
This means that the sum of the digits in the even positions of the number 123456789 is 20.
gistlibby LogSnag