DTMF Dial Function In the class you were given the first part of the function na
ID: 3872112 • Letter: D
Question
DTMF Dial Function In the class you were given the first part of the function named "dtmf.m" to implement a DTMF dialer based on the frequency table defined in Figure 1. Figure 2 is the skeleton of the function presented in the class Row/Column 4 1209Hz 1336Hz1477Hz1633Hz 1 697Hz 2 770Hz 3 852Hz 4 941Hz 4 Figure 1: DTMF Frequency Table function xx=dtmfdial (keyNames, fs) %DTMFDIAL Create signal vector of DTMF tones that will dial a Touch Tone telephone. %usage: xx=dtmfdial (keyNames, f3) keyNames . character string with valid key names fs- sampling frequency xx= signal vector that is the concatenation of DTMF tones 10 11-dtmf.keys-.. 13 14-ff rows [697: 770: 852: 941: 15dtmf.colTones ones (4,1)ff cols: 16- dtmf. rowTones=ff rows* nes (1,4) ; ff_cols-[1209, 1336, 1477, 16331: Figure 2: First part of the dtmf.m (a DTMF phone dialer) Complete this function with additional lines of code so that it implements the following 1. The input to the function is a vector of characters, each one being equal to one of the key names on the telephone. ( The MATLAB structure called dtmf contains the key names in the field dtmf.keys which is a 4 × 4 array that corresponds exactly to the keyboard layout in Fig.1)Explanation / Answer
ANSWER::
function xx = dtmfdial(keyNames,fs)
dtmf.keys = ...
['1','2','3','A';
'4','5','6','B';
'7','8','9','C';
'*','0','#','D'];
dtmf.colTones = ones(4,1)*[1209,1336,1477,1633];
dtmf.rowTones = [697;770;852;941]*ones(1,4);
dur1 = 0.20;
dur2 = 0.05;
tt = 0:1/fs:dur1;
xx = 0;
for ii = 1:length(keyNames)
keyName = keyNames(ii);
[r,c] = find(dtmf.keys==keyName);
if (numel(r) == 0 | numel(c) == 0)
continue
end;
tone = cos(2*pi*dtmf.rowTones(r,c)*tt) + cos(2*pi*dtmf.colTones(r,c)*tt);
xx = [xx, zeros(1, dur2*fs), tone];
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.