# MATLAB: How can i do detection in DTMF ? i want to enter a tone and get the numbers of it

dtmf

i want to enter a tone and get the numbers that consist it ….

dtmf_tones = load('Eng Abeer dtmf.mat');xr  = dtmf_tones.R;fs = dtmf_tones.fs;x = xr - mean(xr);                                  % Remove d-c Component[S,F,T] = spectrogram(x, 1536, 64, 512, fs, 'yaxis');% Fm = repmat(F, 1, length(T));% Tm = repmat(T, length(F), 1);% figure(2)% surf(Fm, Tm, abs(S))% xlabel('Frequency')% ylabel('Time')% axis([0  2000    ylim    zlim])% grid onSa = abs(S);[r, c] = find(Sa >= 20);Fr = F(r);Tc = T(c)';FT = [Tc  Fr];[C, ia, ic] = unique(FT(:,1));                                              % Find Unique Timesfor k1 = 1:size(C,1)                                                        % Create Cell Array By Time    FrqTime{k1} = FT(FT(:,1) == C(k1),:);                                   % Time & Frequency Cell    if size(FrqTime{k1},1) > 2        FrqTime{k1} = [FrqTime{k1}(1,:); mean(FrqTime{k1}(2:end,:))];       % If MoreThan 2 Rows, Second Row Is Mean Of Last 2 Rows    endendFrqTime{1:10}original_f = [697  770  852  941  1209  1336  1477];                        % DTMF Frequenciesdtmf_dcd = [1 5; 1 6; 1 7; 2 5; 2 6; 2 7; 3 5; 3 6; 3 7; 4 5; 4 6; 4 7];    % Combination Codes w.r.t. ‘original_f’nbr_map = ['1' '2' '3' '4' '5' '6' '7' '8' '9' '*' '0' '#'];                % Number Key Mapfor k1 = 1:size(C,1)    freq_dist = abs(bsxfun(@minus, FrqTime{k1}(:,2), original_f));          % Distance Of ‘FrqTime’ Frequencies From ‘original_f’ Frequencies    [~,freq_pos(:,k1)] = min(freq_dist,[],2);                               % Frequency Positions Of ‘FrqTime’ In ‘original_f’    num_pad(k1) = nbr_map(ismember(dtmf_dcd, freq_pos(:,k1)', 'rows'));     % Map To Number Key Padend