产生:
>> symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'};
lfg = [697 770 852 941]; % Low frequency group
hfg = [1209 1336 1477]; % High frequency group
Fs=8000;
lwg=2*pi*lfg/Fs;
hwg=2*pi*hfg/Fs;
a=zeros(2,4);
b=zeros(2,3);
for p=1:4, a(1,p)=sin(lwg(p)); end
for p=1:4, a(2,p)=-2*cos(lwg(p)); end
for q=1:3, b(1,q)=sin(hwg(q)); end
for q=1:3, b(2,q)=-2*cos(hwg(q)); end
for i=1:4, c(i,:)=[0,a(1,i)];
end
d=zeros(4,3);
for i=1:4, d(i,:)=[1,a(2,i),1]; end
e=zeros(3,2);
for i=1:3, e(i,:)=[0,b(1,i)]; end
f=zeros(3,3);
for i=1:3, f(i,:)=[1,b(2,i),1]; end
x=zeros(1,205);
x(1)=1;
for i=1:4, S1(i,:)=filter(c(i,:),d(i,:),x); end
for i=1:3, S2(i,:)=filter(e(i,:),f(i,:),x); end
n=0:204;
for i=1:4,
for j=1:3,
subplot(4,3,3*(i-1)+j), plot(n,S1(i,:)+S2(j,:));title(['Symbol "', symbol{3*(i-1)+j},'":
[',num2str(lfg(i)),',',num2str(hfg(j)),']'])
set(gca, 'XLim', [0 205]);
ylabel('Amplitude');
if (3*(i-1)+j)>9, xlabel('n'); end
end
end
set(gcf, 'Color', [1 1 1], 'Position', [1 1 1280 1024])
annotation(gcf,'textbox', 'Position',[0.38 0.96 0.45 0.026],...
'EdgeColor',[1 1 1],...
'String', '\bf Time response of each tone of the telephone pad', ...
'FitBoxToText','on');
检测:
for i=1:4,
for j=1:3,
X(3*(i-1)+j,:)=S1(i,:)+S2(j,:);
end
end
>> ff=[697 770 852 941 1209 1336 1477];
k=[18,20,22,24,31,34,38];
for choicetone=1:12;
v=zeros(7,3);
for i=1:7,
for j=1:205,
v(i,1)=2*cos(2*pi*k(i)/205)*v(i,2)-v(i,3)+X(choicetone,j);
v(i,3)=v(i,2);
v(i,2)=v(i,1);
end
end
for i=1:7, X2(i)=v(i,1)^2+v(i,2)^2-2*cos(2*pi*k(i)/205)*v(i,1)*v(i,2);
end
subplot(4,3,choicetone),
end
stem(ff,sqrt(X2));