# Signal Generation with MATLAB. Example of DTMF in telephony

In mathematics a signal is a real function of a real variable f(t). In electronics it represents the evolution of a voltage (or a current) over the time and depends on the performances of the stage of the amplifier. Through a memory buffer, samples move to a digital-to-analog converter that produces a voltage signal, after an  amplification stage that can limit the generation of the signal. A possible analysis consists of use Mat lab with a PC sound card and an example of DTMF.

### 1. Introduction

First of all, the information is available in digital format, inside a file in the vector numbers format (samples). Through a memory buffer, samples move to a digital-to-analog converter that produces a voltage signal to output to the external world, after an appropriate amplification stage. Shannon’s theorem states that the sampling frequency fs must satisfy the following relation: fs 2B, where B is the absolute band of the output signal.  Even if the DAC can assure high sampling frequency, the absolute band of the signal that has to be generated depends on the performances of the output stage of the audio card. Because it’s designed for sound applications, it’s equipped with an amplifier with a 200Hz-20KHz bandwidth (in the ideal case). It must be also taken into account that the output signal will be distorted in amplitude and phase, more around the upper cutoff frequency. All that limits the generation of signals having with bandwidth lower than about 10KHz.
At this point, the most important issues are:
1- to generate a file with the signal in the digital format.
2- to setup a hw/sw sysytem able to perform the digital to analog conversion chain (DAC).

### 2. Mat lab and the PC sound card

A possible solution for this problem consists to use Mat lab with a PC sound card. Mat lab is a numerical calculation environment based on matrix structures. It’s able to easily generate a time function (unidimensional vector). Furthermore, through specialized functions, Mat lab is able to generate a .wav format of the signal compatible with all sound player for PC through the sound card. Often, depending on the specific situations, it’s necessary an auxiliary output stage for the audio signal conditioning. Matlab supplies different internal functions to generate a waveform. Most of these require a preliminary statement of a time vector. Considering a sample frequency of fs[Hz] it’s possible to produce a time vector by writing: t=lin space(0, end, end*fs . This command generates a time vector from zero to end second, divided in end*fs points.
The source code to generate a 20Hz, 2 seconds tone is the following:
t=lin space(0, 2, 2*10000)
y=sin(2*pi*20*t)
plot(t, y)
wav write(y, 10000, prova.wav)
The function wav write(y,fs,’Nome file’) generates an audio nomefile.wav file from the y vector sampled at the fs frequency (Figure 2).
Read More: Signal Generation with MATLAB. Example of DTMF in telephony