⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subdig.m

📁 按键式电话如下图所示
💻 M
字号:
%************************* DTMF Identify System *********************


%*************************** DTMF engender ***************************
t=0:0.000125:0.04;  
y=sin(2*pi*f1*t)+sin(2*pi*f2*t);



%******************************* FFT *********************************
fs=8000;% sampling frequency
N=512; % choose the integer power of 2.(N>320)
M=N/2;

Y=fft(y,N); % taking the 512-point fast Fourier transform (FFT)
Pyy=Y.*conj(Y)/N; % The power spectrum
f=fs*(0:M)/N; % Graph the first 257 points (the other 255 points 
              % are redundant) on a meaningful frequency axis



%***************************** Identify ******************************
fi=fft(y,2048);
a=abs(fi);
p=a.*a/10000; % frequency spectrum
num1=find(p(1:250)==max(p(1:250))); % find the row-frequency
num2=299+find(p(300:380)==max(p(300:380))); % find the column-frequency

if (num1 < 180) row=1; % ascertain the row
elseif (num1 < 200) row=2;
elseif (num1 < 220) row=3; 
else row=4;
end


if (num2 < 320) column=1; % ascertain the column
elseif (num2 < 345) column=2;
elseif(num2<373) column=3;
else column=4;
end


z=[row,column]; % ascertain the signal
if     z==[1,1]      set(handles.Press,'String','1');h='1';
    elseif z==[1,2]  set(handles.Press,'String','2'); h='2';
    elseif z==[1,3]  set(handles.Press,'String','3');h='3';
    elseif z==[1,4]  set(handles.Press,'String','A');h='A';
    elseif z==[2,1]  set(handles.Press,'String','4');
    elseif z==[2,2]  set(handles.Press,'String','5');
    elseif z==[2,3]  set(handles.Press,'String','6'); 
    elseif z==[2,4]  set(handles.Press,'String','B'); 
    elseif z==[3,1]  set(handles.Press,'String','7');
    elseif z==[3,2]  set(handles.Press,'String','8');
    elseif z==[3,3]  set(handles.Press,'String','9');
    elseif z==[3,4]  set(handles.Press,'String','C'); 
    elseif z==[4,1]  set(handles.Press,'String','*');
    elseif z==[4,2]  set(handles.Press,'String','0'); 
    elseif z==[4,3]  set(handles.Press,'String','#');
    elseif z==[4,4]  set(handles.Press,'String','D');
end

%***************************** plot *********************************
axes(handles.fig1);
plot(t,y);
set(handles.fig1,'XMinorTick','on');
title('Single wave');xlabel('Time (ms)');
grid;


axes(handles.fig2);
plot(f,Pyy(1:M+1));
title('Frequency spectrum');
xlabel('frequency (Hz)');
grid;


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -