The Table below shows the combinations of tone frequencies used in a touch tone
ID: 2081213 • Letter: T
Question
The Table below shows the combinations of tone frequencies used in a touch tone telephone keypad. Write a Matlab program that prompts the user to enter via keyboard a telephone number (ignore and "a" keys), including the area code, and then plays (using the function sound (D) the corresponding dual tone multiple frequency (DTMF) sequence. Each tone MUST be played at 0.5 seconds at a sampling period of 1/8192 seconds. Your program MUST perform the following tasks: The telephone number entered via keyboard MUST be inputted as a SINGLE STRING. Your program MUST be able to retrieve the 10 digits and take care of different input formats such as: (1232456-7890, 123-456-7890, 1234567890, etc. Your program MUST also verify whether the telephone number entered (excluding characters) has ten digits. If not, your program must display a message to the user and allow him/her to reenter the number without the need to rerun the program. Use the Matlab built-in functions str2double () and isnan() to retrieve the numerical values Plot the tones corresponding to the fourth and the eighth digits entered by the user in the same figure in the time interval [0.20,0.22]. Write inside each plot the corresponding digit and use appropriate axis labels for the plots. Your program MUST also allow the user to START OVER as often he/she wishes, WITHOUT THE NEED to rerun the program.Explanation / Answer
%% Program to decode keypad
clc;
clear;
close all;
%% Program starts here
fs=8192;
Ts=1/8192;
t=0:Ts:0.5;
f1=697;
f2=770;
f3=852;
f4=941;
f5=1209;
f6=1336;
f7=1477;
key1=sin(2*pi*f1*t)+sin(2*pi*f5*t);
key2=sin(2*pi*f1*t)+sin(2*pi*f6*t);
key3=sin(2*pi*f1*t)+sin(2*pi*f7*t);
key4=sin(2*pi*f2*t)+sin(2*pi*f5*t);
key5=sin(2*pi*f2*t)+sin(2*pi*f6*t);
key6=sin(2*pi*f2*t)+sin(2*pi*f7*t);
key7=sin(2*pi*f3*t)+sin(2*pi*f5*t);
key8=sin(2*pi*f3*t)+sin(2*pi*f6*t);
key9=sin(2*pi*f3*t)+sin(2*pi*f7*t);
key0=sin(2*pi*f4*t)+sin(2*pi*f6*t);
prompt='Enter 10 digit Phone Number :';
phone=input(prompt,'s');
if length(phone)~=10
disp('Please Enter correct Phone Number')
end
digits=str2double(phone);
for i=1:10
digits(i)=str2double(phone(i));
switch digits(i)
case 1
sound(key1)
case 2
sound(key2)
case 3
sound(key3)
case 4
sound(key4)
case 5
sound(key5)
case 6
sound(key6)
case 7
sound(key7)
case 8
sound(key8)
case 9
sound(key9)
case 0
sound(key0)
end
pause(1)
end
plot(key4)
OUTPUT:
Enter 10 digit Phone Number :1234567890
>>
LIsten to sound for each digit
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.