Matlab question

Associate
Joined
3 Jul 2005
Posts
887
Location
S.Wales
Could someone point me in the right direction with this question....

Write a program that will read in a text string mixed with numbers and letters from the keyboard and count how many numbers there are in a the string.

Any ideas how i go about doing this? the notes we have been given dont relate to the above question... Do you use ascii code at all? forgive me if this is an easy question but im only a HNC mechatronic student lol ;)

cheers
 
I know nothing about Matlab, but generally, you'd iterate over each of the characters in the input string and check the ASCII value of each one, as you said. If a character is a letter, it will fall in a certain range (in fact two—one for upper case, one for lower case), and a different range if it's a digit.

You can find the ASCII values here:
http://www.asciitable.com/
 
Back
Top Bottom