MATLAB: output the frequency components of a DTMF signal

Click For Summary

Discussion Overview

The discussion revolves around creating a MATLAB function to output the frequency components of a Dual-Tone Multi-Frequency (DTMF) signal based on a numeric symbol input. Participants are exploring the implementation details, syntax issues, and logical structure required for the function.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses uncertainty about how to start the MATLAB function and requests guidance on the initial steps.
  • Another participant explains that DTMF refers to the tones produced by telephone keypad keys and suggests using if...elseif statements to determine the frequency outputs.
  • A participant describes their attempt to implement the function using if...elseif statements but encounters an error regarding variable initialization.
  • Another reply clarifies that the parameter x needs to be assigned a value before calling the function, comparing it to asking for a square root without providing a number.
  • A participant shares their syntax for the function but receives an error related to the use of for loops, indicating a misunderstanding of control structures in MATLAB.
  • One participant points out that the use of for loops is incorrect in this context and recommends using if...elseif statements instead, suggesting that documentation may help clarify control logic.

Areas of Agreement / Disagreement

Participants generally agree on the need to use conditional statements to determine the frequency outputs, but there is disagreement on the correct implementation approach, particularly regarding the use of loops versus conditional statements.

Contextual Notes

There are unresolved issues regarding the proper syntax and structure of the MATLAB function, including variable initialization and the appropriate control flow constructs to use.

makovx
Messages
22
Reaction score
0

Homework Statement



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 _________#


Homework 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)



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.
 
Physics news on Phys.org
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.
 
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?
 
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.
 
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 I've 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
 
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
3K