As much as I dislike doing homework for students, this is a case where I will relent, because it is very uncear why one would subtract 48, and because you have a valid question about MATLAB.
You have a number in a CHARACTER FORM. Thus:
This is NOT stored as a number, but merely a character representation of that number. This is something that many students do not understand the difference. And it is sort of subtle in the eyes of some. Is a picture of something the same as that thing itself? But is a picture of a symbol not just the same symbol? We might start an interesting philsophical debate here. Anyway, MATLAB stores those digits in ascii form when you have such a chacter vector. In the ascii table, they start at element 48.
Now, MATLAB allows one nice trick. You can actually subtract a number from a character string. Or you can even subtract two character strings. See how this works.
Do you see this operation converts the character representation into a true number for each digit?
Personally, I like this next version better, since you don't need to remember where zero appears in the ascii table:
I think now you should see what that code is doing. It converts the characters into true numbers for each digit. Then it sums up the digits you want to sum.