MATLAB: output the frequency components of a DTMF signal

1. Dec 7, 2009

makovx

1. The problem statement, all variables and given/known data

I badly needed an urgent help in Matlab.

I have to create a Matlab function (M-File) that will output the low (flow) and high (fhigh) frequency components of a DTMF signal given the numeric symbol (x) (* and # not included).

I don't even know where to start since this is not discussed. A table is given such that

_______1209 Hz __1336 Hz___1477 Hz
697 Hz____1________2_________3
770 Hz____4________5_________6
852 Hz____7________8_________9
941 Hz____*________0 _________#

2. Relevant equations

Each pair of tones contains one frequency of the low group (697 Hz, 770 Hz, 852 Hz, 941 Hz) and one frequency of the high group (1209 Hz, 1336 Hz, 1477Hz) and represents a unique symbol. What should I do first?

here's the format..

function [flow fhigh]=mydtmf(x)

3. The attempt at a solution

the output must produce something like this...

[flow fhigh]=mydtmf(1)
flow =
697
fhigh =
1209

>> [flow fhigh]=mydtmf(2)
flow =
697

fhigh =
1336

all help would be deeply appreciated.

2. Dec 7, 2009

Staff: Mentor

DTMF = dual-tone multifrequence. These are the tones produced by the keys on a telephone keypad.

Given a digit 0, 1, 2, ... , 9, your routine should set flow and fhigh. Probably the simplest but least elegant way to do this is to use brute force with lots of if ... elseif statements.

3. Dec 8, 2009

makovx

i tried doing the if...for... else..elseif statements but I still can't do it right.
I mean for me to write a function, I have to write something like this

function [flow fhigh]= mydtmf (x)

wherein x is the number 0 to 9.

but it says that variable x is not initialized. what does it mean?
how to initialize the variable x?

4. Dec 8, 2009

Staff: Mentor

It means that the parameter x in your function doesn't have a value yet. Before you call your function you have to give x a value, most likely by input from the keyboard. It's sort of like me asking you to tell me the square root of a number without first telling you the number.

5. Dec 8, 2009

makovx

function [flow fhigh]= mydtmf(x)
x = input('number from 0-9: ')
if x>=0 & x<=9
[flow fhigh]= mydtmf(x)

for x==1,
disp('flow = 697 Hz')
disp('fhigh = 1209 Hz')
end

for x==2,

disp('flow = 697 Hz')
disp('fhigh = 1336 Hz')
end

for x==3,

disp('flow = 697 Hz')
disp('fhigh =1477 Hz')
end

for x==4,

disp('flow = 770 Hz')
disp('fhigh = 1209 Hz')
end

for x==5,

disp('flow = 770 Hz')
disp('fhigh = 1336 Hz')
end

for x==6,

disp('flow = 770 Hz')
disp('fhigh = 1477 Hz')
end

for x==7,

disp('flow = 852 Hz')
disp('fhigh = 1209 Hz')
end

for x==8,

disp('flow = 852 Hz')
disp('fhigh = 1336 Hz')
end

for x==9,

disp('flow = 852 Hz')
disp('fhigh = 1477 Hz')
end

for x==0,

disp('flow = 941 Hz')
disp('fhigh = 1336 Hz')
end
end

this is my syntax. but when i tried to rum it, here's what ive got...

?? Error: File: D:\matlab7\mydtmf.m Line: 6 Column: 10
Missing variable or function.

Line:6 Column 10 is the part of

for x==1

6. Dec 8, 2009

Staff: Mentor

You are (incorrectly) attempting to use for loops when you don't want any loops at all. What you want instead are are series of if ... elseif statements. If you don't have any documentation, here is a link to some that might be helpful -- http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/getstart.pdf. Chapter 4 has information about control logic (including if statements and for loops) and how to write functions.