DTMF双频拨号信号的生成和检测程序%clearall;clc;tm=[1,2,3,65;4,5,6,66;7,8,9,67;42,0,35,68];%DTMF信号代表的16个数N=205;K=[18,20,22,24,31,34,38,42];f1=[697,770,852,941];%行频率向量f2=[1209,1336,1477,1633];%列频率向量TN=input('键入6位电话号码=');%输入6位数字TNr=0;%接收端电话号码初值为零forl=1:6;d=fix(TN/10^(6-l));TN=TN-d*10^(6-l);forp=1:4;forq=1:4;iftm(p,q)==abs(d);break,end%检测码相符的列号qendiftm(p,q)==abs(d);break,end%检测码相符的行号pendn=0:1023;%为了发声,加长序列x=sin(2*pi*n*f1(p)/8000)+sin(2*pi*n*f2(q)/8000);%构成双频信号sound(x,8000);%发出声音pause(0.1)%接收检测端的程序X=goertzel(x(1:205),K+1);%用Goertzel算法计算八点DFT样本val=abs(X);%列出八点DFT向量subplot(3,2,l);stem(K,val,'.');grid;xlabel('k');ylabel('|X(k)|')%画出DFT(k)幅度axis([10500120])limit=80;%fors=5:8;ifval(s)>limit,break,end%查找列号endforr=1:4;ifval(r)>limit,break,end%查找行号endTNr=TNr+tm(r,s-4)*10^(6-l);enddisp('接收端检测到的号码为:')%显示接收到的字符disp(TNr)