How to get digits ( e.g.telephone number) from user and treat each digit separately?

5 views (last 30 days)
Hello. My problem is I want to get digits (e.g.telephone number) from user, like 079389482, but the length of digits unknown. And I want to work on each digit separately, to build dtmf signal (plot) for each digit
  2 Comments
Nursultan Bolatbayev
Nursultan Bolatbayev on 2 Nov 2015
There are many ways. But right now Im trying this: prompt={'Enter your digits by space:'}; title='Dial'; numbers=inputdlg(prompt,title); digits = str2num(numbers{1}); %And I can choose every digit like this a = digits(2); disp(a);

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 2 Nov 2015
Edited: Stephen23 on 2 Nov 2015
If you get the digits as a string then this is easy by simply subtracting '0' from the string:
>> S = input('Please enter your telephone number: ','s');
Please enter your telephone number: 72643
>> V = S-'0'
V =
7 2 6 4 3

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!