MATLAB: Need help for DTMF Scoring fucntion

dtmf

I have written a code for DTMF tone generation. Now for decodiing purpose, i have written code for dtmfscore
function ss = dtmfscor(xx, freq, L, fs)
if (nargin < 4), fs = 8000; end;
hh = (2/L)*cos(2*pi*freq*(0:L-1)/fs);
ss = (mean(conv(xx,hh).^2) > mean(xx.^2)/5);
the book says that input signal xx to dtmfscor function is actually a short segment from DTMF signal.The task of breaking up the signal so that each segment correspond to one key will be done by another function prior to calling dtmfscore.I m confused about xx. how to address this issue
Plz help me and give me rough skecth of algorithm I am stuck for last 2 days

Best Answer

I wouldn't write it like this because the dtmfscor function needs to know which column of tones it needs. But if you call the following:
>>[tones,ss] = dtmfking;
function [tones,ss] = dtmfking
lfg = [697 770 852 941]; % Low frequency group
hfg = [1209 1336 1477]; % High frequency group
% construct table of frequencies
f = [];
for c=1:4,
for r=1:3,
f = [ f [lfg(c);hfg(r)] ];
end
end
Fs = 8000; % Sampling frequency 8 kHz
N = 800; % Tones of 100 ms
t = (0:N-1)/Fs; % 800 samples at Fs
pit = 2*pi*t;
tones = zeros(N,size(f,12));
for toneChoice=1:12,
% Generate tone
tones(:,toneChoice) = sum(sin(f(:,toneChoice)*pit))';
end
ss = dtmfscor(tones,697,20,8000);
%Here i am giving the first freq and first column to cross check
function ss = dtmfscor(tones, freq, L, fs)
if (nargin < 4), fs = 8000; end;
hh = (2/L)*cos(2*pi*freq*(0:L-1)/fs);
ss = (mean(conv(tones(:,1),hh).^2) > mean(tones(:,1).^2)/5);
end
end