Stuck with DTMF code
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to write a DTMF function which takes 5 inputs and give sound for it with gap of 1 seconds. I know how to concatinetane at the end and other stuff but i am stuck how to take data from fucntion input and tell it to assign a desired frequency. Plz Help me
function dtmf=dtmfdial([a b c d e],fs);
%This function produces DTMF Tone corresponding to given
%key number
%abcdefg=input key numbers
%fs= The sampling frequency
fs=8000
lfg = [697 770 852 941]; % Low frequency group
hfg = [1209 1336 1477]; % High frequency group
f = [];
for c=1:4,
for r=1:3,
f = [ f [lfg(c);hfg(r)] ];
end
end
table=f';
dur=.5;
tt=0:(1/fs):dur;
%******************************************************************
%%Here i want to tell MAtlab that if key number 1 is pressed then the
%frequencies will be table (1,1) and table (1,2) and so on
% how to tell matlab about this
%******************************************************************
tone1=sin(2*pi*table(1,1)*tt);
tone2=sin(2*pi*table(1,2)*tt);
tone_a=tone1+tone2
sil_dur=1;
sil_freq=0;
sil_tt=0:(1/fs):dur;
sil_tone=sin(2*pi*sil_freq*sil_tt)
tone1=sin(2*pi*table(3,1)*tt);
tone2=sin(2*pi*table(3,2)*tt);
tone_b=tone1+tone2
soundsc(tone_a,fs);
soundsc(sil_tone,fs);
soundsc(tone_b,fs);
0 commentaires
Réponse acceptée
Honglei Chen
le 6 Oct 2011
You can pass in an array like
function dtmfdial(x,fs)
and then inside your function, use a for loop to work on each key pressed. e.g.,
for m = 1:length(x)
key_pressed = x(m);
% continue to whatever you need to do
end
HTH
0 commentaires
Plus de réponses (4)
Walter Roberson
le 6 Oct 2011
Your line
function dtmf=dtmfdial([a b c d e],fs);
is illegal syntax. It is not allowed to list an array or cell array as a parameter on the right-hand side of a "function" statement.
0 commentaires
moonman
le 6 Oct 2011
1 commentaire
Walter Roberson
le 6 Oct 2011
I had a mandatory all-staff meeting at work this morning, which made my sleep and breakfast schedule rather unbalanced. And now I need to go see if some lunch will wake me up.
Voir également
Catégories
En savoir plus sur DTMF dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!