Can u help me for this part of book, I have written the code but i am stuck now
The next objective is decoding - a process that requires a binary decision on the presence or absence of the individual frequencies. In order to make the signal detection an automated process, we need a score function that rates the different possibilities. (a) Complete the dtmfscor function based on the skeleton given in Table 2. Assume that the input signal xx to the dtmfscor function is actually a short segment from the DTMF signal. The task of breaking up the signal so that each segment corresponds to one key will be done by another function prior to calling dtmfscor. The implementation of the FIR bandpass filter is done with the conv function. The running time of the convolution function is proportional to the filter length L. Therefore, the filter length L must satisfy two competing constraints: L should be large so that the bandwidth of the band pass filter is narrow enough to isolate individual DTMF frequencies, but making it too large will cause the program to run slowly.
Table 2: Skeleton of the dtmfscor.m function
function ss = dtmfscor(xx, freq, L, fs)
if (nargin < 4), fs = 8000; end;
hh =
ss = (mean(conv(xx,hh).^2) > mean(xx.^2)/5);
Here is my effort
function [dtmfseg]=dtmfseg(x);
low_fg = [697 770 852 941];
high_fg = [1209 1336 1477];
f = [];
seg=[];
for a=1:4,
for b=1:3,
f = [ f [low_fg(a);high_fg(b)] ];
end
end
disp('Table of Frequencies is shown')
table=f'
dur=.5;
fs=8000;
tt=0:(1/fs):dur;
n=length(x);
D=cell(1,n);
xx=cell(1,n);
for k=1:n
if x(k)==1
freqa=table(1,1);
freqb=table(1,2);
else if x(k)==2
freqa=table(2,1);
freqb=table(2,2);
else if x(k)==3
freqa=table(3,1);
freqb=table(3,2);
else if x(k)==4
freqa=table(4,1);
freqb=table(4,2);
else if x(k)==5
freqa=table(5,1);
freqb=table(5,2);
else if x(k)==6
freqa=table(6,1);
freqb=table(6,2);
else if x(k)==7
freqa=table(7,1);
freqb=table(7,2);
else if x(k)==8
freqa=table(8,1);
freqb=table(8,2);
else if x(k)==9
freqa=table(9,1);
freqb=table(9,2);
else if x(k)=='*'
freqa=table(10,1);
freqb=table(10,2);
else if x(k)==0
freqa=table(11,1);
freqb=table(11,2);
else x(k)='#';
freqa=table(12,1);
freqb=table(12,2);
end
end
end
end
end
end
end
end
end
end
end
tone1=sin(2*pi*freqa*tt);
tone2=sin(2*pi*freqb*tt);
tone=tone1+tone2;
for w=1:500
seg(w)=tone(w);
sil_dur=.1;
sil_freq=0;
sil_tt=0:(1/fs):sil_dur;
sil_tone=sin(2*pi*sil_freq*sil_tt);
D{k} = [tone,sil_tone];
xx{k}=[seg];
end
dtmfseg = cat(2, xx{:})
Plz Plz guide me and help me